Index: /branches/dev_005_AWL/AGRIF/AA_make
===================================================================
--- /branches/dev_005_AWL/AGRIF/AA_make	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AA_make	(revision 1804)
@@ -13,11 +13,11 @@
 #-Q- sxdkrz C_L	= $(FC_L) 
 #-Q- sxdkrz C_O	= $(FC_O) 
-#-Q- eshpux C_L	= $(FC_L) 
-#-Q- eshpux 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- eshpux 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
@@ -56,5 +56,5 @@
 $(SXMODEL_LIB) : $(OBJS)
 #-Q- sxdkrz     @$(A_X) $@ $(OBJS)
-#-Q- eshpux     @$(A_X) $@ $(OBJS)
+#-Q- es2     @$(A_X) $@ $(OBJS)
 
 $(AGRIFOBJS)/%.o : $(AGRIFFILES)/%.F KEY_CPP
@@ -70,5 +70,5 @@
 #-Q- sx8brodie	mv *.mod $(MODDIR)
 #-Q- sxdkrz	mv *.mod $(MODDIR)
-#-Q- eshpux	mv *.mod $(MODDIR)
+#-Q- es2	mv *.mod $(MODDIR)
 #-Q- solaris	mv *.mod $(MODDIR)
 
Index: /branches/dev_005_AWL/AGRIF/AA_make.ldef
===================================================================
--- /branches/dev_005_AWL/AGRIF/AA_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AA_make.ldef	(revision 1804)
@@ -25,5 +25,5 @@
 SXMODEL_LIB = $(MODEL_LIB)
 #-Q- sxdkrz SXMODEL_LIB = $(LIBDIR)/libsxagrif.a
-#-Q- eshpux SXMODEL_LIB = $(LIBDIR)/libsxagrif.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/libsxagrif.a
 #-
 P_P=$(AGRIF_MPI)
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modbc.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modbc.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modbc.F	(revision 1804)
@@ -814,5 +814,5 @@
       
       CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
-     &                     MPI_COMM_WORLD,code)  
+     &                     MPI_COMM_AGRIF,code)  
      
       lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modinterp.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modinterp.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modinterp.F	(revision 1804)
@@ -894,5 +894,5 @@
 C
       Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
-     &                   MPI_INTEGER,MPI_COMM_WORLD,code)
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
 
       IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var)
@@ -908,5 +908,5 @@
       memberin1(1) = memberin
       CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,
-     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code)
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
 
        Call Get_External_Data_first(tab4t(:,:,1),
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modlinktomodel.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modlinktomodel.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modlinktomodel.F	(revision 1804)
@@ -32,4 +32,5 @@
         external Agrif_probdim_modtype_def
         external Agrif_clustering_def
+        external Agrif_comm_def
 C     Interface                       
       Interface
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modmpp.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modmpp.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modmpp.F	(revision 1804)
@@ -67,5 +67,5 @@
 
          CALL MPI_ALLGATHER(memberout1,1,MPI_LOGICAL,memberoutall,
-     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code)
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
         ENDIF
          pttruetab2(:,Agrif_Procrank) = pttruetab(:,Agrif_Procrank)
@@ -207,5 +207,5 @@
 
          CALL MPI_ALLGATHER(memberout1,1,MPI_LOGICAL,memberoutall,
-     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code)
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
         ENDIF
          pttruetab2(:,Agrif_Procrank) = pttruetab(:,Agrif_Procrank)
@@ -356,5 +356,5 @@
 C
             Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,code)
+     &                    MPI_COMM_AGRIF,code)
 C
             if (sendtoproc(k)) then
@@ -365,5 +365,5 @@
                 Call MPI_SEND(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
 C
                 datasize = 1
@@ -381,5 +381,5 @@
      &                        imin(1,k):imax(1,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(2)
                    Call MPI_SEND(tempC%var%array2(
@@ -387,5 +387,5 @@
      &                        imin(2,k):imax(2,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(3)
                 
@@ -399,5 +399,5 @@
      &                        imin(4,k):imax(4,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(5)
                    Call MPI_SEND(tempC%var%array5(
@@ -408,5 +408,5 @@
      &                        imin(5,k):imax(5,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(6)
                    Call MPI_SEND(tempC%var%array6(
@@ -418,5 +418,5 @@
      &                        imin(6,k):imax(6,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 END SELECT
 C
@@ -432,5 +432,5 @@
 C
             Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,statut,code)
+     &                    MPI_COMM_AGRIF,statut,code)
 C
             recvfromproc(k) = res
@@ -441,5 +441,5 @@
                 Call MPI_RECV(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,statut,code)
+     &                        MPI_COMM_AGRIF,statut,code)
 
                 imin_recv(:,k) = iminmax_temp(:,1,k)
@@ -462,26 +462,26 @@
               Call MPI_RECV(temprecv%var%array1,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(2)
               Call MPI_RECV(temprecv%var%array2,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(3)
               Call MPI_RECV(temprecv%var%array3,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
 
             CASE(4)
               Call MPI_RECV(temprecv%var%array4,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(5)
               Call MPI_RECV(temprecv%var%array5,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(6)
               Call MPI_RECV(temprecv%var%array6,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
        END SELECT
                         
@@ -503,5 +503,5 @@
             
             Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,code)
+     &                    MPI_COMM_AGRIF,code)
 C
             if (sendtoproc(k)) then
@@ -512,5 +512,5 @@
                 Call MPI_SEND(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
 C
                 SELECT CASE(nbdim)
@@ -521,5 +521,5 @@
      &                        imin(1,k):imax(1,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(2)
                 datasize=SIZE(tempC%var%array2(
@@ -530,5 +530,5 @@
      &                        imin(2,k):imax(2,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(3)
                 datasize=SIZE(tempC%var%array3(
@@ -541,5 +541,5 @@
      &                        imin(3,k):imax(3,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(4)
                 datasize=SIZE(tempC%var%array4(
@@ -554,5 +554,5 @@
      &                        imin(4,k):imax(4,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(5)
                 datasize=SIZE(tempC%var%array5(
@@ -569,5 +569,5 @@
      &                        imin(5,k):imax(5,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(6)
                 datasize=SIZE(tempC%var%array6(
@@ -586,5 +586,5 @@
      &                        imin(6,k):imax(6,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 END SELECT
 C
@@ -600,5 +600,5 @@
 C
             Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,statut,code)
+     &                    MPI_COMM_AGRIF,statut,code)
 C
             recvfromproc(k) = res
@@ -609,5 +609,5 @@
                 Call MPI_RECV(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,statut,code)
+     &                        MPI_COMM_AGRIF,statut,code)
 
 C                imin_recv(:,k) = iminmax_temp(:,1,k)
@@ -629,15 +629,15 @@
               Call MPI_RECV(temprecv%var%array1,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
 
             CASE(4)
@@ -645,15 +645,15 @@
               Call MPI_RECV(temprecv%var%array4,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
           END SELECT
             
@@ -693,5 +693,5 @@
 C
             Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,code)
+     &                    MPI_COMM_AGRIF,code)
 C
             if (sendtoproc(k)) then
@@ -702,5 +702,5 @@
                 Call MPI_SEND(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
 C
             endif
@@ -715,5 +715,5 @@
 C
             Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,statut,code)
+     &                    MPI_COMM_AGRIF,statut,code)
 C
             recvfromproc(k) = res
@@ -724,5 +724,5 @@
                 Call MPI_RECV(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,statut,code)
+     &                        MPI_COMM_AGRIF,statut,code)
 
                 imin_recv(:,k) = iminmax_temp(:,1,k)
@@ -739,5 +739,5 @@
             
             Call MPI_SEND(sendtoproc(k),1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,code)
+     &                    MPI_COMM_AGRIF,code)
 C
             if (sendtoproc(k)) then
@@ -748,5 +748,5 @@
                 Call MPI_SEND(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
 C
             endif
@@ -761,5 +761,5 @@
 C
             Call MPI_RECV(res,1,MPI_LOGICAL,k,etiquette,
-     &                    MPI_COMM_WORLD,statut,code)
+     &                    MPI_COMM_AGRIF,statut,code)
 C
             recvfromproc(k) = res
@@ -770,5 +770,5 @@
                 Call MPI_RECV(iminmax_temp(:,:,k),
      &                        2*nbdim,MPI_INTEGER,k,etiquette,
-     &                        MPI_COMM_WORLD,statut,code)
+     &                        MPI_COMM_AGRIF,statut,code)
 
                 imin_recv(:,k) = iminmax_temp(:,1,k)
@@ -842,5 +842,5 @@
      &                        imin(1,k):imax(1,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(2)               
                    Call MPI_SEND(tempC%var%array2(
@@ -848,5 +848,5 @@
      &                        imin(2,k):imax(2,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(3)
      
@@ -860,5 +860,5 @@
      &                        imin(4,k):imax(4,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(5)
                    Call MPI_SEND(tempC%var%array5(
@@ -869,5 +869,5 @@
      &                        imin(5,k):imax(5,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(6)
                    Call MPI_SEND(tempC%var%array6(
@@ -879,5 +879,5 @@
      &                        imin(6,k):imax(6,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 END SELECT
 C
@@ -910,26 +910,26 @@
               Call MPI_RECV(temprecv%var%array1,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(2)           
               Call MPI_RECV(temprecv%var%array2,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(3)       
               Call MPI_RECV(temprecv%var%array3,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
 
             CASE(4)
               Call MPI_RECV(temprecv%var%array4,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(5)
               Call MPI_RECV(temprecv%var%array5,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
             CASE(6)
               Call MPI_RECV(temprecv%var%array6,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
        END SELECT
                         
@@ -958,5 +958,5 @@
      &                        imin(1,k):imax(1,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(2)                
                 datasize=SIZE(tempC%var%array2(
@@ -967,5 +967,5 @@
      &                        imin(2,k):imax(2,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(3)
                 datasize=SIZE(tempC%var%array3(
@@ -978,5 +978,5 @@
      &                        imin(3,k):imax(3,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(4)
                 datasize=SIZE(tempC%var%array4(
@@ -991,5 +991,5 @@
      &                        imin(4,k):imax(4,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(5)
                 datasize=SIZE(tempC%var%array5(
@@ -1006,5 +1006,5 @@
      &                        imin(5,k):imax(5,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 CASE(6)
                 datasize=SIZE(tempC%var%array6(
@@ -1023,5 +1023,5 @@
      &                        imin(6,k):imax(6,k)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
                 END SELECT
 C
@@ -1047,15 +1047,15 @@
               Call MPI_RECV(temprecv%var%array1,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
 
             CASE(4)
@@ -1063,15 +1063,15 @@
               Call MPI_RECV(temprecv%var%array4,
      &               datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &               MPI_COMM_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               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_WORLD,statut,code)
+     &               MPI_COMM_AGRIF,statut,code)
           END SELECT
             
@@ -1108,5 +1108,5 @@
      &                        imin(3):imax(3)),
      &                        datasize,MPI_DOUBLE_PRECISION,k,etiquette,
-     &                        MPI_COMM_WORLD,code)
+     &                        MPI_COMM_AGRIF,code)
      
          End Subroutine Agrif_Send_3Darray
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modtypes.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modtypes.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modtypes.F	(revision 1804)
@@ -37,4 +37,6 @@
       INTEGER, PARAMETER :: Agrif_NbMaxGrids = 10
                   
+C     MPI Communicator
+      INTEGER :: mpi_comm_agrif
 C
 C     **************************************************************************
@@ -409,5 +411,5 @@
       INTEGER :: Agrif_Nbprocs  ! Number of processors
       INTEGER :: Agrif_ProcRank ! Rank of the current processor 
-      INTEGER :: Agrif_Group    ! Group associated to MPI_COMM_WORLD
+      INTEGER :: Agrif_Group    ! Group associated to MPI_COMM_AGRIF
       INTEGER :: Agrif_MPIPREC
 #endif
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modupdate.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modupdate.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modupdate.F	(revision 1804)
@@ -757,5 +757,5 @@
       
       CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
-     &                     MPI_COMM_WORLD,code)
+     &                     MPI_COMM_AGRIF,code)
 
       lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
@@ -925,5 +925,5 @@
       
       CALL MPI_ALLREDUCE(iminmaxg,lubglob,2*nbdim,MPI_INTEGER,MPI_MIN,
-     &                     MPI_COMM_WORLD,code)  
+     &                     MPI_COMM_AGRIF,code)  
      
       lubglob(1:nbdim,2) = - lubglob(1:nbdim,2)      
@@ -1287,5 +1287,5 @@
 C
       Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
-     &                   MPI_INTEGER,MPI_COMM_WORLD,code)
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
 
       IF (.not.associated(tempCextend%var)) Allocate(tempCextend%var)
@@ -1300,5 +1300,5 @@
       memberin1(1) = memberin
       CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,
-     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code)
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
  
        Call Get_External_Data_first(tab4t(:,:,1),
@@ -1419,5 +1419,5 @@
 C
       Call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,
-     &                   MPI_INTEGER,MPI_COMM_WORLD,code)
+     &                   MPI_INTEGER,MPI_COMM_AGRIF,code)
 
       IF (.not.associated(tempPextend%var)) Allocate(tempPextend%var)
@@ -1432,5 +1432,5 @@
       memberin1(1) = member
       CALL MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall2,
-     &                  1,MPI_LOGICAL,MPI_COMM_WORLD,code)
+     &                  1,MPI_LOGICAL,MPI_COMM_AGRIF,code)
  
       Call Get_External_Data_first(tab5t(:,:,1),
Index: /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modutil.F
===================================================================
--- /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modutil.F	(revision 1803)
+++ /branches/dev_005_AWL/AGRIF/AGRIF_FILES/modutil.F	(revision 1804)
@@ -63,12 +63,29 @@
 C
 #ifdef AGRIF_MPI
-      Integer      :: code
+      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_WORLD,Agrif_Nbprocs,code)
-          Call MPI_COMM_RANK(MPI_COMM_WORLD,Agrif_ProcRank,code)
-          Call MPI_COMM_GROUP(MPI_COMM_WORLD,Agrif_Group,code)
+          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
Index: /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -456,5 +456,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -462,5 +462,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -476,5 +476,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -495,5 +495,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -501,5 +501,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -531,5 +531,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -543,5 +543,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -550,5 +550,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/GYRE/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux  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- eshpux  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
 SXMODEL_LIB = $(MODEL_LIB)
 #-Q- sxdkrz  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
-#-Q- eshpux  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml
===================================================================
--- /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/EXP00/iodef.xml	(revision 1804)
@@ -250,4 +250,7 @@
     -->
 
+  <file_definition output_level="10" enabled=".TRUE.">
+
+
       <group id="1h" output_freq="3600"   output_level="10" enabled=".TRUE.">                      <!-- 1h files -->
       </group>
Index: /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -585,5 +585,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -591,5 +591,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -605,5 +605,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -624,5 +624,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -630,5 +630,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -660,5 +660,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -672,5 +672,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -679,5 +679,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/GYRE_LOBSTER/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux  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- eshpux 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- eshpux  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/CONFIG/ORCA2_LIM/EXP00/iodef.xml
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM/EXP00/iodef.xml	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM/EXP00/iodef.xml	(revision 1804)
@@ -560,3 +560,380 @@
   </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_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -463,5 +463,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -469,5 +469,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -483,5 +483,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -502,5 +502,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -508,5 +508,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -538,5 +538,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -550,5 +550,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -557,5 +557,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux 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- eshpux 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- eshpux SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_pisces	(revision 1804)
@@ -25,5 +25,5 @@
    xkmort     =  1.E-7   ! half saturation constant for mortality
    ferat3     =  3.E-6   ! Fe/C in zooplankton 
-   wsbio2     =  50.     ! Big particles sinking speed
+   wsbio2     =  30.     ! Big particles sinking speed
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -32,5 +32,5 @@
    conc0      =  2.e-6    ! Phosphate half saturation
    conc1      =  10E-6    ! Phosphate half saturation for diatoms
-   conc2      =  0.02E-9  ! Iron half saturation for phyto
+   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
@@ -46,6 +46,6 @@
 &nampisprod     !   parameters for phytoplankton growth
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   pislope    =  4.       ! P-I slope  
-   pislope2   =  4.       ! P-I slope  for diatoms
+   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
@@ -87,7 +87,7 @@
    resrat     =  0.03     ! exsudation rate of zooplankton
    mzrat      =  0.0      ! zooplankton mortality rate
-   xpref2c    =  0.0      ! Microzoo preference for POM 
-   xpref2p    =  0.5      ! Microzoo preference for Nanophyto
-   xpref2d    =  0.5      ! Microzoo preference for Diatoms
+   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
Index: /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -588,5 +588,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -594,5 +594,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -608,5 +608,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -627,5 +627,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -633,5 +633,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -663,5 +663,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -675,5 +675,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -682,5 +682,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_LIM_PISCES/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux 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- eshpux 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- eshpux SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 1804)
@@ -128,8 +128,8 @@
     lperdyn   = .true.     ! periodicity of the unique file (T)
 !                          ! F  (default)   computed with Blanke' scheme 
-    cfile_grid_T = 'NEMOV3_5d_20910101_20911231_grid_T.nc' ! name of grid_T file
-    cfile_grid_U = 'NEMOV3_5d_20910101_20911231_grid_U.nc' ! name of grid_U file
-    cfile_grid_V = 'NEMOV3_5d_20910101_20911231_grid_V.nc' ! name of grid_V file
-    cfile_grid_W = 'NEMOV3_5d_20910101_20911231_grid_W.nc' ! name of grid_W file
+    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_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_pisces	(revision 1804)
@@ -25,5 +25,5 @@
    xkmort     =  1.E-7   ! half saturation constant for mortality
    ferat3     =  3.E-6   ! Fe/C in zooplankton 
-   wsbio2     =  50.     ! Big particles sinking speed
+   wsbio2     =  30.     ! Big particles sinking speed
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -32,5 +32,5 @@
    conc0      =  2.e-6    ! Phosphate half saturation
    conc1      =  10E-6    ! Phosphate half saturation for diatoms
-   conc2      =  0.02E-9  ! Iron half saturation for phyto
+   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
@@ -46,6 +46,6 @@
 &nampisprod     !   parameters for phytoplankton growth
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-   pislope    =  4.       ! P-I slope  
-   pislope2   =  4.       ! P-I slope  for diatoms
+   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
@@ -87,7 +87,7 @@
    resrat     =  0.03     ! exsudation rate of zooplankton
    mzrat      =  0.0      ! zooplankton mortality rate
-   xpref2c    =  0.0      ! Microzoo preference for POM 
-   xpref2p    =  0.5      ! Microzoo preference for Nanophyto
-   xpref2d    =  0.5      ! Microzoo preference for Diatoms
+   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
@@ -175,3 +175,4 @@
 !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
    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_005_AWL/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/IGCM00/COMP/pisces.card	(revision 1804)
@@ -17,8 +17,8 @@
 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_20910101_20911231_grid_T.nc, .), \
-            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_20910101_20911231_grid_U.nc, .), \
-            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_20910101_20911231_grid_V.nc, .), \
-            (${R_BC}/${config_UserChoices_TagName}/DYN/${pisces_UserChoices_OPA_dyn}/NEMOV3_5d_20910101_20911231_grid_W.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, .), \
Index: /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -390,5 +390,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -396,5 +396,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -410,5 +410,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -429,5 +429,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -435,5 +435,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -465,5 +465,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -477,5 +477,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -484,5 +484,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/ORCA2_OFF_PISCES/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux 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- eshpux 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- eshpux SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
+#-Q- es2 SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make
===================================================================
--- /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make	(revision 1804)
@@ -22,10 +22,10 @@
 #-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- eshpux  # Compiler options for NEMO (Earth Simulator)
-#-Q- eshpux  # for super perfs!
-#-Q- eshpux  # 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- eshpux  # regular options!
-#-Q- eshpux  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- eshpux  L_X = $(L_O)
+#-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)
@@ -62,5 +62,5 @@
 #-Q- sx8brodie	PREF=i.
 #-Q- sxdkrz	PREF=i.
-#-Q- eshpux	PREF=i.
+#-Q- es2	PREF=i.
 
 # add suffix to P_P
@@ -456,5 +456,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix6		-qsource \
 #-Q- aix		-qsource \
@@ -462,5 +462,5 @@
 	   OPAFILES/$*.F90 || { mv $(PREF).L $(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
+#-Q- es2			@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
 endif
 
@@ -476,5 +476,5 @@
 .PRECIOUS : $(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : $(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : $(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : $(SXMODEL_LIB)
 
 # library dependancies
@@ -495,5 +495,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -501,5 +501,5 @@
 		$*.f90 || { if [ -f $(PREF)$*.L ] ; then mv $(PREF)$*.L $(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
@@ -531,5 +531,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -543,5 +543,5 @@
 #-Q- sx8brodie		-R2 \
 #-Q- sxdkrz		-R2 \
-#-Q- eshpux		-R2 \
+#-Q- es2		-R2 \
 #-Q- aix		-qsource \
 #-Q- aix6		-qsource \
@@ -550,5 +550,5 @@
 endif
 #-Q- sxdkrz		@$(A_X) $(SXMODEL_LIB) $*.o  > /dev/null
-#-Q- eshpux		@$(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]
Index: /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make.ldef
===================================================================
--- /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make.ldef	(revision 1803)
+++ /branches/dev_005_AWL/CONFIG/POMME/scripts/BB_make.ldef	(revision 1804)
@@ -14,11 +14,11 @@
 IOIPSL_LIB = $(LIBDIR)/libioipsl.a
 #-Q- sxdkrz  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
-#-Q- eshpux  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- eshpux  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
 SXMODEL_LIB = $(MODEL_LIB)
 #-Q- sxdkrz  SXMODEL_LIB = $(LIBDIR)/oce/libsxopa.a
-#-Q- eshpux  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
+#-Q- es2  IOIPSL_LIB = $(LIBDIR)/libsxioipsl.a
 OASISMPI2_LIB = 
 LIBMPI  =
@@ -37,5 +37,5 @@
 #-Q- sx9mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/EXTERNAL/XMLF90/AA_make
===================================================================
--- /branches/dev_005_AWL/EXTERNAL/XMLF90/AA_make	(revision 1803)
+++ /branches/dev_005_AWL/EXTERNAL/XMLF90/AA_make	(revision 1804)
@@ -11,5 +11,5 @@
 #-
 #-Q- sxdkrz F_O = $(F_D) $(F_P) -C vsafe -size_t64 -I $(MODDIR)
-#-Q- eshpux F_O = $(F_D) $(F_P) -C vsafe -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)
Index: /branches/dev_005_AWL/EXTERNAL/XMLF90/makemake_XMLF90.perl
===================================================================
--- /branches/dev_005_AWL/EXTERNAL/XMLF90/makemake_XMLF90.perl	(revision 1803)
+++ /branches/dev_005_AWL/EXTERNAL/XMLF90/makemake_XMLF90.perl	(revision 1804)
@@ -31,5 +31,5 @@
 print MAKEFILE "#-\n";
 print MAKEFILE "#-Q- sxdkrz F_O = \$(F_D) \$(F_P) -C vsafe -size_t64 -I \$(MODDIR)\n";
-print MAKEFILE "#-Q- eshpux F_O = \$(F_D) \$(F_P) -C vsafe -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";
Index: /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/AA_make
===================================================================
--- /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/AA_make	(revision 1803)
+++ /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/AA_make	(revision 1804)
@@ -15,5 +15,5 @@
 #-Q- sx9mercure F_O := $(F_O) -Wf,-ptr byte
 #-Q- sxdkrz F_O := $(F_O) -Wf,-ptr byte
-#-Q- eshpux 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)
Index: /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl
===================================================================
--- /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl	(revision 1803)
+++ /branches/dev_005_AWL/EXTERNAL/XMLIO_SERVER/makemake_XMLIO.perl	(revision 1804)
@@ -35,5 +35,5 @@
 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- eshpux 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";
Index: /branches/dev_005_AWL/NEMO/NST_SRC/agrif2model.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/NST_SRC/agrif2model.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/NST_SRC/agrif2model.F90	(revision 1804)
@@ -73,4 +73,23 @@
 
    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
Index: /branches/dev_005_AWL/NEMO/OFF_SRC/DOM/domrea.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OFF_SRC/DOM/domrea.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OFF_SRC/DOM/domrea.F90	(revision 1804)
@@ -215,11 +215,10 @@
 
  
-         DO jk = 1,jpk
-            gdept(:,:,jk) = gdept_0(jk)
-            gdepw(:,:,jk) = gdepw_0(jk)
-         END DO
-         
-
          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
@@ -233,5 +232,5 @@
             END IF
 
-            IF( nmsh <= 3 ) THEN                                   !    ! 3D depth
+            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 )
@@ -240,4 +239,9 @@
               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
@@ -252,12 +256,8 @@
                 END DO
               END DO
+
             ENDIF
 
          ENDIF
-         ! 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
          IF( ln_zco ) THEN
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/dianam.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/dianam.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/dianam.F90	(revision 1804)
@@ -129,7 +129,5 @@
  
       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    
+      IF( .NOT. Agrif_Root() ) cdfnam = TRIM(Agrif_CFixed())//'_'//TRIM(cdfnam)
 
    END SUBROUTINE dia_nam
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/diawri.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DIA/diawri.F90	(revision 1804)
@@ -629,7 +629,5 @@
       ! Define name, frequency of output and means
       clname = cdfile_name
-#if defined key_agrif
-      if ( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
-#endif
+      IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//'_'//TRIM(clname)
       zdt  = rdt
       zsto = rdt
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 1804)
@@ -219,4 +219,13 @@
 #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
 
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domain.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domain.F90	(revision 1804)
@@ -166,21 +166,17 @@
       ENDIF
 
-#if defined key_agrif
       IF( Agrif_Root() ) THEN
-#endif
-      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
-#if defined key_agrif
-      ENDIF
-#endif
+         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)
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domhgr.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 1804)
@@ -270,5 +270,5 @@
          
 #if defined key_agrif && defined key_eel_r6
-         IF (.Not.Agrif_Root()) THEN
+         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
@@ -465,5 +465,5 @@
          
 #if defined key_agrif && defined key_eel_r6
-         IF (.Not.Agrif_Root()) THEN
+         IF( .NOT. Agrif_Root() ) THEN
            zphi0 = ppgphi0 - FLOAT( Agrif_Parent(jpjglo)/2)*Agrif_Parent(ppe2_m) / (ra * rad)
          ENDIF
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/divcur.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/divcur.F90	(revision 1804)
@@ -123,33 +123,27 @@
 
 #if defined key_obc
-#if defined key_agrif
-         IF (Agrif_Root() ) THEN
-#endif
-         ! 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
-#if defined key_agrif
-         ENDIF
-#endif
+         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
+            DO ji = 1, jpi
+               hdivn(ji,jj,jk)=hdivn(ji,jj,jk)*bdytmask(ji,jj)
+            END DO
          END DO
 #endif         
-#if defined key_agrif
-         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
-#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
 
          !                                             ! --------
@@ -341,16 +335,12 @@
 
 #if defined key_obc
-#if defined key_agrif
-         IF ( Agrif_Root() ) THEN
-#endif
-         ! 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
-#if defined key_agrif
-         ENDIF
-#endif
+         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
@@ -362,12 +352,10 @@
          END DO
 #endif        
-#if defined key_agrif
-         if ( .NOT. AGRIF_Root() ) then
+         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
-#endif    
+         ENDIF
 
          !                                             ! --------
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 1804)
@@ -330,5 +330,5 @@
       END DO
 
-#if defined key_agrif      
+#if defined key_agrif
       IF( .NOT. Agrif_Root() ) THEN
          ! caution : grad D (fine) = grad D (coarse) at coarse/fine interface
@@ -338,5 +338,6 @@
          IF( nbondj ==  1 .OR. nbondj == 2 ) spgv(:,nlcj-2) = z2dtg * z2dt * laplacv(:,nlcj-2) * vmask(:,nlcj-2,1)
       ENDIF
-#endif      
+#endif
+
       ! Add the trends multiplied by z2dt to the after velocity
       ! -------------------------------------------------------
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 1804)
@@ -157,12 +157,8 @@
 
 #if defined key_obc
-# if defined key_agrif
       IF ( Agrif_Root() ) THEN 
-# endif
          ssha(:,:) = ssha(:,:) * obctmsk(:,:)
          CALL lbc_lnk( ssha, 'T', 1. )  ! absolutly compulsory !! (jmm)
-# if defined key_agrif
-      ENDIF
-# endif
+      ENDIF
 #endif
 
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/IOM/iom.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/IOM/iom.F90	(revision 1804)
@@ -43,5 +43,5 @@
    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
+   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
@@ -86,5 +86,6 @@
       !!----------------------------------------------------------------------
       ! read the xml file
-      CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)...
+      IF( Agrif_Root() ) CALL event__parse_xml_file( 'iodef.xml' )   ! <- to get from the nameliste (namrun)...
+      CALL iom_swap
 
       ! calendar parameters
@@ -119,4 +120,22 @@
 
    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
 
 
@@ -164,10 +183,4 @@
       ! 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
@@ -176,5 +189,4 @@
          ENDIF
       ENDIF
-#endif
       ! do we read or write the file?
       IF( PRESENT(ldwrt) ) THEN   ;   llwrt = ldwrt
@@ -199,5 +211,4 @@
       ! =============
       clname   = trim(cdname)
-#if defined key_agrif
       IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
          iln    = INDEX(clname,'/') 
@@ -206,5 +217,4 @@
          clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
       ENDIF
-#endif    
       ! which suffix should we use?
       SELECT CASE (iolib)
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 1804)
@@ -86,12 +86,10 @@
 !!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 defined key_agrif
+
       IF ( Agrif_Root() ) THEN
-#endif
         IF( lk_lim2 )            nn_ice      = 2
         IF( lk_lim3 )            nn_ice      = 3
-#if defined key_agrif
-      ENDIF
-#endif
+      ENDIF
+      !
       IF( cp_cfg == 'gyre' ) THEN
           ln_ana      = .TRUE.   
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/SOL/solmat.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/SOL/solmat.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/SOL/solmat.F90	(revision 1804)
@@ -142,6 +142,5 @@
 #endif
 
-#if defined key_agrif
-      IF( .NOT.AGRIF_ROOT() ) THEN
+      IF( .NOT. Agrif_Root() ) THEN   ! Fine grid boundaries
          !
          IF( nbondi == -1 .OR. nbondi == 2 )   bmask(2     ,:     ) = 0.e0
@@ -192,5 +191,4 @@
          ! 
       ENDIF
-#endif
 
       ! 2. Boundary conditions 
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/lib_mpp.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/lib_mpp.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/lib_mpp.F90	(revision 1804)
@@ -112,5 +112,7 @@
    INTEGER ::   mppsize        ! number of process
    INTEGER ::   mpprank        ! process number  [ 0 - size-1 ]
-   INTEGER ::   mpi_comm_opa   ! opa local communicator
+!$AGRIF_DO_NOT_TREAT
+   INTEGER, PUBLIC ::   mpi_comm_opa   ! opa local communicator
+!$AGRIF_END_DO_NOT_TREAT
 
    ! variables used in case of sea-ice
@@ -191,67 +193,13 @@
       WRITE(ldtxt(6),*) '      size in bytes of exported buffer   nn_buffer   = ', nn_buffer
 
-#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
-            WRITE(*, cform_err)
-            WRITE(*, *) '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 ( 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
-#endif
-            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
-
-#if ! defined key_agrif
-            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
-#endif
-#if defined key_agrif
-      ELSE
+      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)
@@ -259,4 +207,5 @@
          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)'
@@ -267,8 +216,41 @@
             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
 
-      mpi_comm_opa = mpi_comm_world
-#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 )
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/opa.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/opa.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/opa.F90	(revision 1804)
@@ -156,5 +156,7 @@
       CALL opa_closefile
 #if defined key_oasis3 || defined key_oasis4
-      CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
+      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
@@ -191,8 +193,12 @@
 #if defined key_iomput
 # if defined key_oasis3 || defined key_oasis4
-      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)
+      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
-      CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
+      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
@@ -200,5 +206,7 @@
 #else
 # if defined key_oasis3 || defined key_oasis4
-      CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
+      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
Index: /branches/dev_005_AWL/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/OPA_SRC/step.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/OPA_SRC/step.F90	(revision 1804)
@@ -166,6 +166,9 @@
 #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( 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
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trclsm_c14b.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trclsm_c14b.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trclsm_c14b.F90	(revision 1804)
@@ -44,5 +44,5 @@
       INTEGER ::   numnatb
 
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
       ! definition of additional diagnostic as a structure
       INTEGER ::   jl, jn
@@ -58,5 +58,5 @@
       !!
       NAMELIST/namc14date/ ndate_beg_b, nyear_res_b
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
       NAMELIST/namc14dia/nwritedia, c14dia2d, c14dia3d     ! additional diagnostics
 #endif
@@ -81,5 +81,5 @@
       IF(lwp) WRITE(numout,*) '    initial year (aa)                  nyear_beg_b = ', nyear_beg_b
       !
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
 
       ! Namelist namc14dia
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trcrst_c14b.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 1804)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/C14b/trcrst_c14b.F90	(revision 1804)
@@ -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_005_AWL/NEMO/TOP_SRC/CFC/trcctl_cfc.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trcctl_cfc.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trcctl_cfc.F90	(revision 1804)
@@ -44,6 +44,5 @@
       IF( jp_cfc > 2) THEN 
           IF(lwp) THEN 
-              WRITE (numout,*) ' ===>>>> : w a r n i n g '
-              WRITE (numout,*) ' =======   ============= '
+              WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
               WRITE (numout,*)                             &
               &   ' STOP, change jp_cfc to 1 or 2 in par_CFC module '  
@@ -62,6 +61,5 @@
 
       IF(lwp) THEN
-         WRITE (numout,*) ' ===>>>> : w a r n i n g '
-         WRITE (numout,*) ' =======   ============= '
+         WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
          WRITE (numout,*) ' we force tracer names'
          DO jl = 1, jp_cfc
@@ -80,6 +78,5 @@
             ctrcun(jn) = 'mole/m3'
             IF(lwp) THEN
-               WRITE (numout,*) ' ===>>>> : w a r n i n g '
-               WRITE (numout,*) ' =======   ============= '
+               WRITE (numout,*) ' ===>>>> : w a r n i n g <<<<==='
                WRITE (numout,*) ' we force tracer unit'
                WRITE(numout,*) ' tracer  ',ctrcnm(jn), 'UNIT= ',ctrcun(jn)
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trclsm_cfc.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trclsm_cfc.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trclsm_cfc.F90	(revision 1804)
@@ -43,5 +43,5 @@
       !!----------------------------------------------------------------------
       INTEGER ::   numnatc
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
       ! definition of additional diagnostic as a structure
       INTEGER :: jl, jn
@@ -56,5 +56,5 @@
       !!
       NAMELIST/namcfcdate/ ndate_beg, nyear_res
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
       NAMELIST/namcfcdia/nwritedia, cfcdia2d     ! additional diagnostics
 #endif
@@ -79,5 +79,5 @@
       IF(lwp) WRITE(numout,*) '    initial year (aa)                       nyear_beg = ', nyear_beg
       !
-#if defined key_trc_diaadd
+#if defined key_trc_diaadd && ! defined key_iomput
 
       ! Namelist namcfcdia
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trcrst_cfc.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 1804)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/CFC/trcrst_cfc.F90	(revision 1804)
@@ -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_005_AWL/NEMO/TOP_SRC/LOBSTER/trcbio.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcbio.F90	(revision 1804)
@@ -482,4 +482,6 @@
       ENDIF
 
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
          WRITE(charout, FMT="('bio')")
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcexp.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcexp.F90	(revision 1804)
@@ -164,4 +164,6 @@
       ENDIF
 
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
          WRITE(charout, FMT="('exp')")
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcini_lobster.F90	(revision 1804)
@@ -26,5 +26,4 @@
    PUBLIC   trc_ini_lobster   ! called by trcini.F90 module
 
-#  include "domzgr_substitute.h90"
 #  include "top_substitute.h90"
    !!----------------------------------------------------------------------
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcopt.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcopt.F90	(revision 1804)
@@ -28,5 +28,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 1804)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcrst_lobster.F90	(revision 1804)
@@ -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_005_AWL/NEMO/TOP_SRC/LOBSTER/trcsed.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/LOBSTER/trcsed.F90	(revision 1804)
@@ -29,5 +29,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
@@ -136,4 +136,6 @@
       ENDIF
 
+      IF( l_trdtrc ) DEALLOCATE( ztrbio )
+
       IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
          WRITE(charout, FMT="('sed')")
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90	(revision 1804)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/MY_TRC/trcrst_my_trc.F90	(revision 1804)
@@ -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_005_AWL/NEMO/TOP_SRC/PISCES/p4zbio.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zbio.F90	(revision 1804)
@@ -39,5 +39,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zche.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zche.F90	(revision 1804)
@@ -147,5 +147,5 @@
 
    !!* Substitution
-#include "domzgr_substitute.h90"
+#include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zflx.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zflx.F90	(revision 1804)
@@ -52,5 +52,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zlim.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zlim.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zlim.F90	(revision 1804)
@@ -41,5 +41,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmeso.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmeso.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmeso.F90	(revision 1804)
@@ -45,5 +45,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmicro.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmicro.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmicro.F90	(revision 1804)
@@ -43,5 +43,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmort.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmort.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zmort.F90	(revision 1804)
@@ -41,5 +41,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zopt.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zopt.F90	(revision 1804)
@@ -35,5 +35,5 @@
    
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zprod.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zprod.F90	(revision 1804)
@@ -53,5 +53,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zrem.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zrem.F90	(revision 1804)
@@ -45,5 +45,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zsink.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/p4zsink.F90	(revision 1804)
@@ -69,5 +69,5 @@
 
    !!* Substitution
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 2.0 , LOCEAN-IPSL (2007) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/sms_pisces.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/sms_pisces.F90	(revision 1804)
@@ -38,4 +38,6 @@
    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
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 1804)
@@ -38,5 +38,4 @@
       no3    =  31.04e-6 * 7.6
 
-#  include "domzgr_substitute.h90"
 #  include "top_substitute.h90"
    !!----------------------------------------------------------------------
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trclsm_pisces.F90	(revision 1804)
@@ -67,5 +67,5 @@
       NAMELIST/nampisdia/ nwritedia, pisdia3d, pisdia2d     ! additional diagnostics
 #endif
-      NAMELIST/nampisdmp/ ln_pisdmp
+      NAMELIST/nampisdmp/ ln_pisdmp, ln_pisclo
 
       !!----------------------------------------------------------------------
@@ -188,5 +188,6 @@
          WRITE(numout,*)
          WRITE(numout,*) ' Namelist : nampisdmp'
-         WRITE(numout,*) '    Relaxation of tracer to glodap mean value    ln_pisdmp      =', ln_pisdmp
+         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
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 1804)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/PISCES/trcrst_pisces.F90	(revision 1804)
@@ -0,0 +1,303 @@
+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
+      nmonth = 1
+      nday   = 1
+      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_005_AWL/NEMO/TOP_SRC/TRP/trctrp.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 1804)
@@ -53,5 +53,5 @@
 
    !! * Substitutions
-#  include "domzgr_substitute.h90"
+#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005) 
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_imp.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_imp.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_imp.F90	(revision 1804)
@@ -112,38 +112,40 @@
          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
 
-	 ! 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
 	 zwt( 1 ,:,:) = 0.e0     ;     zwt(jpi,:,:) = 0.e0     
          zwt(  :,:,1) = 0.e0     ;     zwt(  :,:,jpk) = 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
          
          ! Second member construction
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso.F90	(revision 1804)
@@ -182,6 +182,23 @@
 
 
-
-      DO jn = 1, jptra
+      ! 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
@@ -262,19 +279,4 @@
             END DO
 
-
-            ! I.3  update and save of avt (and avs if double diffusive mixing)
-            ! ---------------------------
-
-            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
 
 #if defined key_trcldf_eiv
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/TRP/trczdf_iso_vopt.F90	(revision 1804)
@@ -154,5 +154,5 @@
                             zws   => va      ! workspace
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
-      INTEGER ::   ji, jj, jk, jn            ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jn            ! dummy loop indices
       REAL(wp) ::   zavi, zrhs               ! temporary scalars
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   &
@@ -180,4 +180,89 @@
       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) )
 
@@ -187,12 +272,4 @@
          
          IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)          ! save trends
-         
-         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
 
 #  if defined key_trc_diatrd
@@ -200,83 +277,4 @@
          ztrd(:,:,:) = tra(:,:,:,jn)
 #  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
-         ! ------------------------        
-         ! 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
 
          ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/trcdta.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/trcdta.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/trcdta.F90	(revision 1804)
@@ -25,4 +25,5 @@
    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
 
@@ -62,5 +63,6 @@
       !!
       CHARACTER (len=39) ::   clname(jptra)
-      INTEGER, PARAMETER ::   jpmois  = 12        ! number of months
+      INTEGER, PARAMETER ::   &
+         jpmonth = 12    ! number of months
       INTEGER ::   ji, jj, jn, jl 
       INTEGER ::   imois, iman, i15, ik  ! temporary integers 
@@ -81,5 +83,5 @@
             ENDIF
             ! Initialization
-            iman = jpmois
+            iman = jpmonth
             i15  = nday / 16
             imois = nmonth + i15 -1
@@ -188,4 +190,5 @@
             ! 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(:,:,:)
@@ -204,4 +207,5 @@
    !!   Dummy module                              NO 3D passive tracer data
    !!----------------------------------------------------------------------
+   LOGICAL , PUBLIC, PARAMETER ::   lk_dtatrc = .FALSE.   !: temperature data flag
 CONTAINS
    SUBROUTINE trc_dta( kt )        ! Empty routine
Index: /branches/dev_005_AWL/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- /branches/dev_005_AWL/NEMO/TOP_SRC/trcrst.F90	(revision 1803)
+++ /branches/dev_005_AWL/NEMO/TOP_SRC/trcrst.F90	(revision 1804)
@@ -1,10 +1,19 @@
 MODULE trcrst
    !!======================================================================
-   !!                       ***  MODULE trcrst  ***
-   !! TOP :   create, write, read the restart files for passive tracers
+   !!                         ***  MODULE trcrst  ***
+   !! TOP :   Manage the passive tracer restart
    !!======================================================================
-   !! History :   1.0  !  2007-02 (C. Ethe) adaptation from the ocean
+   !! 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
@@ -16,22 +25,21 @@
    USE oce_trc
    USE trc
-   USE sms_lobster         ! LOBSTER variables
-   USE sms_pisces          ! PISCES variables
-   USE trcsms_cfc          ! CFC variables
-   USE trcsms_c14b         ! C14 variables
-   USE trcsms_my_trc       ! MY_TRC variables
-   USE trctrp_lec   
+   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
+
    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
@@ -89,6 +97,5 @@
    END SUBROUTINE trc_rst_opn
 
-
-   SUBROUTINE trc_rst_read 
+   SUBROUTINE trc_rst_read
       !!----------------------------------------------------------------------
       !!                    ***  trc_rst_opn  ***
@@ -96,14 +103,9 @@
       !! ** purpose  :   read passive tracer fields in restart files
       !!----------------------------------------------------------------------
-      INTEGER  ::  jn  
-      INTEGER  ::  iarak0
+      INTEGER  ::  jn     
+      INTEGER  ::  iarak0 
       REAL(wp) ::  zarak0
       INTEGER  ::  jlibalt = jprstlib
       LOGICAL  ::  llok
-#if defined key_pisces 
-      INTEGER  ::  ji, jj, jk
-      REAL(wp) ::  zcaralk, zbicarb, zco3
-      REAL(wp) ::  ztmas, ztmas1
-#endif
 
       !!----------------------------------------------------------------------
@@ -115,10 +117,10 @@
       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
+        ! 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 )
+        IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF 
+      ENDIF
+
+      CALL iom_open( cn_trcrst_in, numrtr, kiolib = jlibalt ) 
 
       ! Time domain : restart
@@ -136,65 +138,24 @@
          & ' 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 defined key_lobster
-      CALL iom_get( numrtr, jpdom_autoglo, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) ) 
-      CALL iom_get( numrtr, jpdom_autoglo, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) ) 
-#endif
-#if defined key_pisces
-      !
-      IF( ln_pisdmp ) CALL pis_dmp_ini  ! relaxation of some tracers
-      !
-      IF( iom_varid( numrtr, 'PH', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numrtr, 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( numrtr, jpdom_autoglo, 'Silicalim', xksi(:,:) ) 
-      IF( iom_varid( numrtr, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numrtr, jpdom_autoglo, 'Silicamax' , xksimax(:,:)  )
-      ELSE
-         xksimax(:,:) = xksi(:,:)
-      ENDIF
-#endif
-#if defined key_cfc
-      DO jn = jp_cfc0, jp_cfc1
-         CALL iom_get( numrtr, jpdom_autoglo, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jn) ) 
-      END DO
-#endif
-#if defined key_c14b
-      CALL iom_get( numrtr, jpdom_autoglo, 'qint_'//ctrcnm(jn) , qint_c14(:,:) ) 
-#endif
-#if defined key_my_trc
-#endif
-      
+         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 )
@@ -218,6 +179,6 @@
       CALL iom_rstput( kt, nitrst, numrtw, 'arak0', zarak0 )
 
-      ! prognostic variables
-      ! --------------------
+      ! prognostic variables 
+      ! -------------------- 
       DO jn = 1, jptra
          CALL iom_rstput( kt, nitrst, numrtw, 'TRN'//ctrcnm(jn), trn(:,:,:,jn) )
@@ -228,24 +189,10 @@
       END DO
 
-#if defined key_lobster
-         CALL iom_rstput( kt, nitrst, numrtw, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) )
-         CALL iom_rstput( kt, nitrst, numrtw, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) )
-#endif
-#if defined key_pisces 
-         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:) )
-         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:) )
-         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
-#endif
-#if defined key_cfc
-         DO jn = jp_cfc0, jp_cfc1
-            CALL iom_rstput( kt, nitrst, numrtw, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jn) )
-         END DO
-#endif
-#if defined key_c14b
-         CALL iom_rstput( kt, nitrst, numrtw, 'qint_'//ctrcnm(jn), qint_c14(:,:) )
-#endif
-#if defined key_my_trc
-#endif
-      
+      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
@@ -256,5 +203,6 @@
       ENDIF
       !
-   END SUBROUTINE trc_rst_wri
+   END SUBROUTINE trc_rst_wri 
+
 
    SUBROUTINE trc_rst_cal( kt, cdrw )
@@ -347,117 +295,4 @@
    END SUBROUTINE trc_rst_cal
 
-# if defined key_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
-         siomean = 91.51      ! mean value of silicate
-      
-      REAL(wp) ::   zvol, ztrasum
-
-
-      IF(lwp)  WRITE(numout,*)
-
-      IF( cp_cfg == "orca" .AND. .NOT. lk_trc_c1d ) THEN      ! ORCA condiguration (not 1D) !
-         !                                                    ! --------------------------- !
-         ! set total alkalinity, phosphate, NO3 & silicate
-
-         ! total alkalinity
-         ztrasum = 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
-                  ztrasum = ztrasum + trn(ji,jj,jk,jptal) * zvol
-               END DO
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( ztrasum )     ! sum over the global domain  
-         
-         ztrasum = ztrasum / areatot * 1.e6
-         IF(lwp) WRITE(numout,*) '       TALK mean : ', ztrasum
-         trn(:,:,:,jptal) = trn(:,:,:,jptal) * alkmean / ztrasum
-            
-         ! phosphate
-         ztrasum = 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
-                  ztrasum = ztrasum + trn(ji,jj,jk,jppo4) * zvol
-               END DO
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( ztrasum )     ! sum over the global domain  
-         
-         ztrasum = ztrasum / areatot * 1.e6 / 122.
-         IF(lwp) WRITE(numout,*) '       PO4  mean : ', ztrasum
-         trn(:,:,:,jppo4) = trn(:,:,:,jppo4) * po4mean / ztrasum
-        
-         ! Nitrates          
-         ztrasum = 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
-                  ztrasum = ztrasum + trn(ji,jj,jk,jpno3) * zvol
-               END DO
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( ztrasum )     ! sum over the global domain  
-         
-         ztrasum = ztrasum / areatot * 1.e6 / 7.6
-         IF(lwp) WRITE(numout,*) '       NO3  mean : ', ztrasum
-         trn(:,:,:,jpno3) = trn(:,:,:,jpno3) * no3mean / ztrasum
-         
-         ! Silicate
-         ztrasum = 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
-                  ztrasum = ztrasum + trn(ji,jj,jk,jpsil) * zvol
-               END DO
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( ztrasum )     ! sum over the global domain  
-         ztrasum = ztrasum / areatot * 1.e6
-         IF(lwp) WRITE(numout,*) '       SiO3 mean : ', ztrasum
-         trn(:,:,:,jpsil) = MIN( 400.e-6,trn(:,:,:,jpsil) * siomean / ztrasum ) 
-         !
-      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
-
-#endif
-      !!----------------------------------------------------------------------
 
    SUBROUTINE trc_rst_stat
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE	(revision 1804)
@@ -38,5 +38,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_GYRE_LOBSTER	(revision 1804)
@@ -38,5 +38,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM	(revision 1804)
@@ -39,5 +39,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM3	(revision 1804)
@@ -39,5 +39,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_LIM_PISCES	(revision 1804)
@@ -38,5 +38,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ORCA2_OFF_PISCES	(revision 1804)
@@ -38,5 +38,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF
===================================================================
--- /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/INSTALL/CONFIG_FILES/BB_make.ldef_ZAGRIF	(revision 1804)
@@ -38,5 +38,5 @@
 #-Q- sx8mercure prefix = -D
 #-Q- sx8brodie prefix = -D
-#-Q- eshpux prefix = -D
+#-Q- es2 prefix = -D
 #-Q- sxdkrz prefix = -D
 #-Q- linux  prefix = -D
Index: /branches/dev_005_AWL/NVTK/fait_AA_make
===================================================================
--- /branches/dev_005_AWL/NVTK/fait_AA_make	(revision 1803)
+++ /branches/dev_005_AWL/NVTK/fait_AA_make	(revision 1804)
@@ -126,5 +126,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix6		-qsource \\
 #-Q- babel		-qsource \\
@@ -143,5 +143,5 @@
 .PRECIOUS : \$(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : \$(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : \$(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : \$(SXMODEL_LIB)
 
 # library dependancies
@@ -161,5 +161,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix6		-qsource \\
 #-Q- babel		-qsource \\
@@ -192,5 +192,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix6		-qsource \\
 #-Q- babel		-qsource \\
@@ -202,5 +202,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix6		-qsource \\
 #-Q- babel		-qsource \\
@@ -240,10 +240,10 @@
 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- eshpux  # Compiler options for NEMO (Earth Simulator)'
-echo '#-Q- eshpux  # for super perfs!'
-echo '#-Q- eshpux  # 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- eshpux  # regular options!'
-echo '#-Q- eshpux  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- eshpux  L_X = $(L_O)'
+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)'
@@ -276,5 +276,5 @@
 echo '#-Q- sx8brodie	PREF=i.'
 echo '#-Q- sxdkrz	PREF=i.'
-echo '#-Q- eshpux	PREF=i.'
+echo '#-Q- es2	PREF=i.'
 echo ''
 echo '#Run type: mon, mpi or omp '
Index: /branches/dev_005_AWL/UTIL/CFG_TOOLS/Makefile
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/Makefile	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/Makefile	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/agrif_readwrite.f90
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/agrif_readwrite.f90	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/agrif_readwrite.f90	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/agrif_types.f90
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/agrif_types.f90	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/agrif_types.f90	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/cfg_tools.f90
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/cfg_tools.f90	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/cfg_tools.f90	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/create_coordinates.f90
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/create_coordinates.f90	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/create_coordinates.f90	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/io_netcdf.f90
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/io_netcdf.f90	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/io_netcdf.f90	(revision 1804)
@@ -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_005_AWL/UTIL/CFG_TOOLS/namelist
===================================================================
--- /branches/dev_005_AWL/UTIL/CFG_TOOLS/namelist	(revision 1804)
+++ /branches/dev_005_AWL/UTIL/CFG_TOOLS/namelist	(revision 1804)
@@ -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_005_AWL/UTIL/fait_AA_make
===================================================================
--- /branches/dev_005_AWL/UTIL/fait_AA_make	(revision 1803)
+++ /branches/dev_005_AWL/UTIL/fait_AA_make	(revision 1804)
@@ -86,5 +86,5 @@
 
 # Agrif library and conv
-libagrif :  \$(call keycompat,key_iomput,key_agrif)
+libagrif :
 ifeq (\$(AGRIF),use)
 	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
@@ -112,5 +112,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix6		-qsource \\
 #-Q- aix		-qsource \\
@@ -118,5 +118,5 @@
 	   OPAFILES/\$*.F90 || { mv \$(PREF).L \$(TMP) ; false ; exit ; }
 #-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
-#-Q- eshpux			@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- es2			@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
 endif
 
@@ -132,5 +132,5 @@
 .PRECIOUS : \$(MODEL_LIB)
 #-Q- sxdkrz .PRECIOUS : \$(SXMODEL_LIB)
-#-Q- eshpux .PRECIOUS : \$(SXMODEL_LIB)
+#-Q- es2 .PRECIOUS : \$(SXMODEL_LIB)
 
 # library dependancies
@@ -151,5 +151,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix		-qsource \\
 #-Q- aix6		-qsource \\
@@ -157,5 +157,5 @@
 		\$*.f90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
 #-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
-#-Q- eshpux		@\$(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]
@@ -187,5 +187,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix		-qsource \\
 #-Q- aix6		-qsource \\
@@ -199,5 +199,5 @@
 #-Q- sx8brodie		-R2 \\
 #-Q- sxdkrz		-R2 \\
-#-Q- eshpux		-R2 \\
+#-Q- es2		-R2 \\
 #-Q- aix		-qsource \\
 #-Q- aix6		-qsource \\
@@ -206,5 +206,5 @@
 endif
 #-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
-#-Q- eshpux		@\$(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]
@@ -245,10 +245,10 @@
 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- eshpux  # Compiler options for NEMO (Earth Simulator)'
-echo '#-Q- eshpux  # for super perfs!'
-echo '#-Q- eshpux  # 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- eshpux  # regular options!'
-echo '#-Q- eshpux  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- eshpux  L_X = $(L_O)'
+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)'
@@ -286,5 +286,5 @@
 echo '#-Q- sx8brodie	PREF=i.'
 echo '#-Q- sxdkrz	PREF=i.'
-echo '#-Q- eshpux	PREF=i.'
+echo '#-Q- es2	PREF=i.'
 echo ''
 echo '# add suffix to P_P'
@@ -327,5 +327,5 @@
 
 echo '#check key compatibility'
-echo 'keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))'
+echo 'keycompat=$(if $(word 2, $(findstring $1,$(P_P)) $(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))'
 
 echo ''
