Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/ARCH/arch-ALTIX_NAUTILUS_MPT.fcm
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/ARCH/arch-ALTIX_NAUTILUS_MPT.fcm	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/ARCH/arch-ALTIX_NAUTILUS_MPT.fcm	(revision 4233)
@@ -47,5 +47,5 @@
 %LD                  ifort
 %FPPFLAGS            -P -C -traditional
-%LDFLAGS             -lmpi -lstdc++
+%LDFLAGS             -lmpi -lstdc++ -lcurl
 %AR                  ar 
 %ARFLAGS             -r
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/AMM12/EXP00/namelist
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/AMM12/EXP00/namelist	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/AMM12/EXP00/namelist	(revision 4233)
@@ -553,4 +553,17 @@
    ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
 /
 !----------------------------------------------------------------------------------
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/iodef.xml
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/iodef.xml	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/iodef.xml	(revision 4233)
@@ -47,9 +47,15 @@
 	  <field field_ref="mldr10_1"     name="somxl010"  />
 	  <field field_ref="mldkz5"       name="somixhgt"  />
-        </file>
+           <!-- variables available with MLE
+          <field field_ref="Lf_NHpf"    name="Lf_NHpf"  long_name="MLE:_Lf=NH/f"     />
+	   -->
+       </file>
 	
 	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
           <field field_ref="uoce"         name="vozocrtx"  />
           <field field_ref="utau"         name="sozotaux"  />
+          <!-- variables available with MLE
+          <field field_ref="psiu_mle"     name="psiu_mle"  long_name="MLE_streamfunction_along_i-axis" />
+	  -->
         </file>
 	
@@ -57,4 +63,7 @@
           <field field_ref="voce"         name="vomecrty"  /> 
           <field field_ref="vtau"         name="sometauy"  /> 
+          <!-- variables available with MLE
+          <field field_ref="psiv_mle"     name="psiv_mle"  long_name="MLE_streamfunction_along_j-axis" />
+	  -->
         </file>
 	
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/namelist
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/namelist	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE/EXP00/namelist	(revision 4233)
@@ -589,4 +589,17 @@
    ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
 /
 !----------------------------------------------------------------------------------
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist	(revision 4233)
@@ -589,4 +589,17 @@
    ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
 /
 !----------------------------------------------------------------------------------
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/iodef.xml
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/iodef.xml	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/iodef.xml	(revision 4233)
@@ -47,4 +47,7 @@
 	  <field field_ref="mldr10_1"     name="somxl010"  />
 	  <field field_ref="mldkz5"       name="somixhgt"  />
+           <!-- variables available with MLE
+          <field field_ref="Lf_NHpf"    name="Lf_NHpf"  long_name="MLE:_Lf=NH/f"     />
+	   -->
         </file>
 	
@@ -52,4 +55,7 @@
           <field field_ref="uoce"         name="vozocrtx"  />
           <field field_ref="utau"         name="sozotaux"  />
+          <!-- variables available with MLE
+          <field field_ref="psiu_mle"     name="psiu_mle"  long_name="MLE_streamfunction_along_i-axis" />
+	  -->
         </file>
 	
@@ -57,4 +63,7 @@
           <field field_ref="voce"         name="vomecrty"  /> 
           <field field_ref="vtau"         name="sometauy"  /> 
+          <!-- variables available with MLE
+          <field field_ref="psiv_mle"     name="psiv_mle"  long_name="MLE_streamfunction_along_j-axis" />
+	  -->
         </file>
 	
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/iodef_default.xml
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/iodef_default.xml	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/iodef_default.xml	(revision 4233)
@@ -67,4 +67,7 @@
 	  <field field_ref="mldkz5"       />
 	  <field field_ref="mldr10_1"     />
+           <!-- variables available with MLE
+          <field field_ref="Lf_NHpf"    name="Lf_NHpf"  long_name="MLE:_Lf=NH/f"     />
+	   -->
 	</file>
 	
@@ -73,4 +76,7 @@
 	  <field field_ref="suoce"        name="uos"     long_name="sea_surface_x_velocity"    />
 	  <field field_ref="utau"         name="tauuo"   long_name="surface_downward_x_stress" />
+          <!-- variables available with MLE
+          <field field_ref="psiu_mle"     name="psiu_mle"  long_name="MLE_streamfunction_along_i-axis" />
+	  -->
 	</file>
 	
@@ -79,4 +85,7 @@
 	  <field field_ref="svoce"        name="vos"     long_name="sea_surface_y_velocity"    />
 	  <field field_ref="vtau"         name="tauvo"   long_name="surface_downward_y_stress" />
+          <!-- variables available with MLE
+          <field field_ref="psiv_mle"     name="psiv_mle"  long_name="MLE_streamfunction_along_j-axis" />
+	  -->
 	</file>
 	
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist	(revision 4233)
@@ -584,4 +584,17 @@
    ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
+/
+ !-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
 /
 !----------------------------------------------------------------------------------
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/iodef.xml	(revision 4233)
@@ -66,5 +66,8 @@
 	  <field field_ref="erp"          name="sowafldp"  />
 	  <field field_ref="ist_ipa"      name="soicetem"  />
-	  <field field_ref="icealb_cea"   name="soicealb"  />   
+	  <field field_ref="icealb_cea"   name="soicealb"  /> 
+           <!-- variables available with MLE
+          <field field_ref="Lf_NHpf"    name="Lf_NHpf"  long_name="MLE:_Lf=NH/f"     />
+	   -->
 	</file>
 	
@@ -73,4 +76,7 @@
 	  <field field_ref="uoce_eiv"     name="vozoeivu"  />
 	  <field field_ref="utau"         name="sozotaux"  />
+          <!-- variables available with MLE
+          <field field_ref="psiu_mle"     name="psiu_mle"  long_name="MLE_streamfunction_along_i-axis" />
+	  -->
 	</file>
 	
@@ -79,4 +85,7 @@
 	  <field field_ref="voce_eiv"     name="vomeeivv"  />
 	  <field field_ref="vtau"         name="sometauy"  />
+          <!-- variables available with MLE
+          <field field_ref="psiv_mle"     name="psiv_mle"  long_name="MLE_streamfunction_along_j-axis" />
+	  -->
 	</file>
 	
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist	(revision 4233)
@@ -565,4 +565,17 @@
    ln_traadv_qck    =  .false.  !  QUICKEST scheme
    ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
 /
 !-----------------------------------------------------------------------
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 4233)
@@ -29,4 +29,6 @@
          <field id="mldr10_1"     long_name="Mixed Layer Depth 0.01 ref.10m"            unit="m"                        />
          <field id="rhop"         long_name="potential density (sigma0)"                unit="kg/m3" grid_ref="grid_T_3D"/>
+         <!-- variables available with MLE -->
+         <field id="Lf_NHpf"      long_name="MLE: Lf = N H / f"                         unit="m"                        />
          <!-- next variables available with key_diahth -->
          <field id="mlddzt"       long_name="Thermocline Depth (max dT/dz)"             unit="m"                        />
@@ -140,4 +142,6 @@
          <field id="uoce"         long_name="ocean current along i-axis"                  unit="m/s"  grid_ref="grid_U_3D" />
          <field id="uocetr_eff"   long_name="Effective ocean transport along i-axis"      unit="m3/s" grid_ref="grid_U_3D" />
+         <!-- variables available with MLE -->
+         <field id="psiu_mle"     long_name="MLE streamfunction along i-axis"             unit="m3/s"  grid_ref="grid_U_3D"  />
          <!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
          <field id="uoce_eiv"     long_name="EIV ocean current along i-axis"              unit="m/s"  grid_ref="grid_U_3D" />
@@ -159,4 +163,6 @@
          <field id="voce"         long_name="ocean current along j-axis"                  unit="m/s"  grid_ref="grid_V_3D" />
          <field id="vocetr_eff"   long_name="Effective ocean transport along j-axis"      unit="m3/s" grid_ref="grid_V_3D" />
+         <!-- variables available with MLE -->
+         <field id="psiv_mle"     long_name="MLE streamfunction along j-axis"             unit="m3/s"  grid_ref="grid_V_3D"  />
          <!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
          <field id="voce_eiv"     long_name="EIV ocean current along j-axis"              unit="m/s"  grid_ref="grid_V_3D" />
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 4233)
@@ -6,4 +6,5 @@
    !! History :  2.0  !  2005-11  (G. Madec)  Original code
    !!            3.3  !  2010-09  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
+   !!            4.0  !  2011-06  (G. Madec)  Addition of Mixed Layer Eddy parameterisation
    !!----------------------------------------------------------------------
 
@@ -21,4 +22,5 @@
    USE traadv_qck      ! QUICKEST scheme           (tra_adv_qck    routine)
    USE traadv_eiv      ! eddy induced velocity     (tra_adv_eiv    routine)
+   USE traadv_mle      ! ML eddy induced velocity  (tra_adv_mle    routine)
    USE cla             ! cross land advection      (cla_traadv     routine)
    USE ldftra_oce      ! lateral diffusion coefficient on tracers
@@ -99,4 +101,5 @@
          &              CALL tra_adv_eiv( kt, nit000, zun, zvn, zwn, 'TRA' )    ! add the eiv transport (if necessary)
       !
+      IF( ln_mle    )   CALL tra_adv_mle( kt, nit000, zun, zvn, zwn, 'TRA' )    ! add the mle transport (if necessary)
       CALL iom_put( "uocetr_eff", zun )                                         ! output effective transport      
       CALL iom_put( "vocetr_eff", zvn )
@@ -136,5 +139,5 @@
          &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv')
+      IF( nn_timing == 1 )  CALL timing_stop( 'tra_adv' )
       !
       CALL wrk_dealloc( jpi, jpj, jpk, zun, zvn, zwn )
@@ -206,4 +209,6 @@
       ENDIF
       !
+      CALL tra_adv_mle_init          ! initialisation of the Mixed Layer Eddy parametrisation (MLE)
+      !
    END SUBROUTINE tra_adv_init
 
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90	(revision 4233)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90	(revision 4233)
@@ -0,0 +1,347 @@
+MODULE traadv_mle
+   !!======================================================================
+   !!                    ***  MODULE  traadv_mle  ***
+   !! Ocean tracers: Mixed Layer Eddy induced transport
+   !!======================================================================
+   !! History :  3.3  !  2010-08  (G. Madec)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_mle      : update the effective transport with the Mixed Layer Eddy induced transport
+   !!   tra_adv_mle_init : initialisation of the Mixed Layer Eddy induced transport computation
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE phycst         ! physical constant
+   USE zdfmxl         ! mixed layer depth
+   USE lbclnk         ! lateral boundary condition / mpp link
+   USE in_out_manager ! I/O manager
+   USE iom            ! IOM library
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! work arrays
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_mle        ! routine called in traadv.F90
+   PUBLIC   tra_adv_mle_init   ! routine called in traadv.F90
+
+   !                                               !!* namelist namtra_adv_mle *
+   LOGICAL, PUBLIC ::   ln_mle    = .TRUE.          ! flag to activate the Mixed Layer Eddy (MLE) parameterisation
+   INTEGER         ::   nn_mle    = 0               ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   INTEGER         ::   nn_mld_uv = 0               ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   INTEGER         ::   nn_conv   = 0               ! =1 no MLE in case of convection ; =0 always MLE
+   REAL(wp)        ::   rn_ce   = 0.06_wp           ! MLE coefficient
+   !                                                ! parameters used in nn_mle = 0 case
+   REAL(wp)        ::   rn_lf   = 5.e+3_wp               ! typical scale of mixed layer front
+   REAL(wp)        ::   rn_time = 2._wp * 86400._wp      ! time scale for mixing momentum across the mixed layer
+   !                                                ! parameters used in nn_mle = 1 case
+   REAL(wp)        ::   rn_lat  = 20._wp                 ! reference latitude for a 5 km scale of ML front
+   REAL(wp)        ::   rn_rho_c_mle  = 0.01        ! Density criterion for definition of MLD used by FK
+
+   REAL(wp) ::   r5_21 = 5.e0 / 21.e0   ! factor used in mle streamfunction computation
+   REAL(wp) ::   rb_c                   ! ML buoyancy criteria = g rho_c /rau0 where rho_c is defined in zdfmld
+   REAL(wp) ::   rc_f                   ! MLE coefficient (= rn_ce / (5 km * fo) ) in nn_mle=1 case
+
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   rfu, rfv   ! modified Coriolis parameter (f+tau) at u- & v-pts
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   r1_ft      ! inverse of the modified Coriolis parameter at t-pts
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! $Id:$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_adv_mle( kt, kit000, pu, pv, pw, cdtype )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE adv_mle  ***
+      !!
+      !! ** Purpose :   Add to the transport the Mixed Layer Eddy induced transport
+      !!
+      !! ** Method  :   The 3 components of the Mixed Layer Eddy (MLE) induced
+      !!              transport are computed as follows :
+      !!                zu_mle = dk[ zpsi_uw ]
+      !!                zv_mle = dk[ zpsi_vw ]
+      !!                zw_mle = - di[ zpsi_uw ] - dj[ zpsi_vw ]
+      !!                where zpsi is the MLE streamfunction at uw and vw points (see the doc)
+      !!              and added to the input velocity :
+      !!                p.n = p.n + z._mle
+      !!
+      !! ** Action  : - (pun,pvn,pwn) increased by the mle transport
+      !!                CAUTION, the transport is not updated at the last line/raw
+      !!                         this may be a problem for some advection schemes
+      !!
+      !! References: Fox-Kemper et al., JPO, 38, 1145-1165, 2008
+      !!             Fox-Kemper and Ferrari, JPO, 38, 1166-1179, 2008
+      !!----------------------------------------------------------------------
+      !
+      INTEGER                         , INTENT(in   ) ::   kt         ! ocean time-step index
+      INTEGER                         , INTENT(in   ) ::   kit000     ! first time step index
+      CHARACTER(len=3)                , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pu         ! in : 3 ocean transport components
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pv         ! out: same 3  transport components
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pw         !   increased by the MLE induced transport
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ikmax        ! temporary integer
+      REAL(wp) ::   zcuw, zmuw   ! local scalar
+      REAL(wp) ::   zcvw, zmvw   !   -      -
+      REAL(wp) ::   zc                                     !   -      -
+
+      INTEGER  ::   ii, ij, ik              ! local integers
+      INTEGER, DIMENSION(3) ::   ilocu      !
+      INTEGER, DIMENSION(2) ::   ilocs      !
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_NH, zLf_MH
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpsi_uw, zpsi_vw
+      INTEGER, POINTER, DIMENSION(:,:) :: inml_mle
+      !!----------------------------------------------------------------------
+
+      IF( nn_timing == 1 )  CALL timing_start('tra_adv_mle')
+      CALL wrk_alloc( jpi, jpj, zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_NH, zLf_MH)
+      CALL wrk_alloc( jpi, jpj, jpk, zpsi_uw, zpsi_vw)
+      CALL wrk_alloc( jpi, jpj, inml_mle)
+      !
+      !                                      !==  MLD used for MLE  ==!
+      !                                                ! compute from the 10m density to deal with the diurnal cycle
+      inml_mle(:,:) = mbkt(:,:) + 1                    ! init. to number of ocean w-level (T-level + 1)
+      DO jk = jpkm1, nlb10, -1                         ! from the bottom to nlb10 (10m)
+         DO jj = 1, jpj
+            DO ji = 1, jpi                             ! index of the w-level at the ML based
+               IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + rn_rho_c_mle )   inml_mle(ji,jj) = jk      ! Mixed layer
+            END DO
+         END DO
+      END DO
+      ikmax = MAXVAL( inml_mle(:,:) )                  ! max level of the computation
+      !
+      !
+      zmld(:,:) = 0._wp                      !==   Horizontal shape of the MLE  ==!
+      zbm (:,:) = 0._wp
+      zn2 (:,:) = 0._wp
+      DO jk = 1, ikmax                                 ! MLD and mean buoyancy and N2 over the mixed layer
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zc = fse3t(ji,jj,jk) * REAL( MIN( MAX( 0, inml_mle(ji,jj)-jk ) , 1  )  )    ! zc being 0 outside the ML t-points
+               zmld(ji,jj) = zmld(ji,jj) + zc
+               zbm (ji,jj) = zbm (ji,jj) + zc * (rau0 - rhop(ji,jj,jk) ) * r1_rau0
+               zn2 (ji,jj) = zn2 (ji,jj) + zc * (rn2(ji,jj,jk)+rn2(ji,jj,jk+1))*0.5_wp
+            END DO
+         END DO
+      END DO
+
+      SELECT CASE( nn_mld_uv )                         ! MLD at u- & v-pts
+      CASE ( 0 )                                               != min of the 2 neighbour MLDs
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zhu(ji,jj) = MIN( zmld(ji+1,jj), zmld(ji,jj) )
+               zhv(ji,jj) = MIN( zmld(ji,jj+1), zmld(ji,jj) )
+            END DO
+         END DO
+      CASE ( 1 )                                               != average of the 2 neighbour MLDs
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zhu(ji,jj) = ( zmld(ji+1,jj) + zmld(ji,jj) ) * 0.5_wp
+               zhv(ji,jj) = ( zmld(ji,jj+1) + zmld(ji,jj) ) * 0.5_wp
+            END DO
+         END DO
+      CASE ( 2 )                                               != max of the 2 neighbour MLDs
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zhu(ji,jj) = MAX( zmld(ji+1,jj), zmld(ji,jj) )
+               zhv(ji,jj) = MAX( zmld(ji,jj+1), zmld(ji,jj) )
+            END DO
+         END DO
+      END SELECT
+      !                                                ! convert density into buoyancy
+      zbm(:,:) = + grav * zbm(:,:) / MAX( fse3t(:,:,1), zmld(:,:) )
+      !
+      !
+      !                                      !==  Magnitude of the MLE stream function  ==!
+      !
+      !                 di[bm]  Ds
+      ! Psi = Ce  H^2 ---------------- e2u  mu(z)   where fu Lf = MAX( fu*rn_fl , (Db H)^1/2 )
+      !                  e1u   Lf fu                      and the e2u for the "transport"
+      !                                                      (not *e3u as divided by e3u at the end)
+      !
+      IF( nn_mle == 0 ) THEN           ! Fox-Kemper et al. 2010 formulation
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zpsim_u(ji,jj) = rn_ce * zhu(ji,jj) * zhu(ji,jj)  * e2u(ji,jj)                                            &
+                  &           * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp          , e1u(ji,jj)                 )   &
+                  &           / (         e1u(ji,jj)          * MAX( rn_lf * rfu(ji,jj) , SQRT( rb_c * zhu(ji,jj) ) )   )
+                  !
+               zpsim_v(ji,jj) = rn_ce * zhv(ji,jj) * zhv(ji,jj)  * e1v(ji,jj)                                            &
+                  &           * ( zbm(ji,jj+1) - zbm(ji,jj) ) * MIN( 111.e3_wp          , e2v(ji,jj)                 )   &
+                  &           / (         e2v(ji,jj)          * MAX( rn_lf * rfv(ji,jj) , SQRT( rb_c * zhv(ji,jj) ) )   )
+            END DO
+         END DO
+         !
+      ELSEIF( nn_mle == 1 ) THEN       ! New formulation (Lf = 5km fo/ff with fo=Coriolis parameter at latitude rn_lat)
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zpsim_u(ji,jj) = rc_f *   zhu(ji,jj)   * zhu(ji,jj)   * e2u(ji,jj) / e1u(ji,jj)          &
+                  &                  * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp , e1u(ji,jj) )
+                  !
+               zpsim_v(ji,jj) = rc_f *   zhv(ji,jj)   * zhv(ji,jj)   * e1v(ji,jj) / e2v(ji,jj)          &
+                  &                  * ( zbm(ji,jj+1) - zbm(ji,jj) ) * MIN( 111.e3_wp , e2v(ji,jj) )
+            END DO
+         END DO
+      ENDIF
+      !
+      IF( nn_conv == 1 ) THEN              ! No MLE in case of convection
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               IF( MIN( zn2(ji,jj) , zn2(ji+1,jj) ) < 0._wp )   zpsim_u(ji,jj) = 0._wp
+               IF( MIN( zn2(ji,jj) , zn2(ji,jj+1) ) < 0._wp )   zpsim_v(ji,jj) = 0._wp
+            END DO
+         END DO
+      ENDIF
+      !
+      !                                      !==  structure function value at uw- and vw-points  ==!
+      zhu(:,:) = 1._wp / zhu(:,:)                   ! hu --> 1/hu
+      zhv(:,:) = 1._wp / zhv(:,:)
+      zpsi_uw(:,:,:) = 0._wp
+      zpsi_vw(:,:,:) = 0._wp
+      !
+      DO jk = 2, ikmax                                ! start from 2 : surface value = 0
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zcuw = 1._wp - ( fsdepw(ji+1,jj,jk) + fsdepw(ji,jj,jk) ) * zhu(ji,jj)
+               zcvw = 1._wp - ( fsdepw(ji,jj+1,jk) + fsdepw(ji,jj,jk) ) * zhv(ji,jj)
+               zcuw = zcuw * zcuw
+               zcvw = zcvw * zcvw
+               zmuw = MAX(  0._wp , ( 1._wp - zcuw ) * ( 1._wp + r5_21 * zcuw )  )
+               zmvw = MAX(  0._wp , ( 1._wp - zcvw ) * ( 1._wp + r5_21 * zcvw )  )
+               !
+               zpsi_uw(ji,jj,jk) = zpsim_u(ji,jj) * zmuw * umask(ji,jj,jk)
+               zpsi_vw(ji,jj,jk) = zpsim_v(ji,jj) * zmvw * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      !                                      !==  transport increased by the MLE induced transport ==!
+      DO jk = 1, ikmax
+         DO jj = 1, jpjm1                          ! CAUTION pu,pv must be defined at row/column i=1 / j=1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               pu(ji,jj,jk) = pu(ji,jj,jk) + ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji,jj,jk+1) )
+               pv(ji,jj,jk) = pv(ji,jj,jk) + ( zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj,jk+1) )
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               pw(ji,jj,jk) = pw(ji,jj,jk) - ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji-1,jj,jk)   &
+                  &                          + zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj-1,jk) )
+            END DO
+         END DO
+      END DO
+
+      IF( cdtype == 'TRA') THEN              !==  outputs  ==!
+         !
+         zLf_NH(:,:) = SQRT( rb_c * zmld(:,:) ) * r1_ft(:,:)      ! Lf = N H / f
+         CALL iom_put( "Lf_NHpf" , zLf_NH  )    ! Lf = N H / f
+         !
+         ! divide by cross distance to give streamfunction with dimensions m^2/s
+         DO jk = 1, ikmax+1
+            zpsi_uw(:,:,jk) = zpsi_uw(:,:,jk)/e2u(:,:)
+            zpsi_vw(:,:,jk) = zpsi_vw(:,:,jk)/e1v(:,:)
+         END DO
+         CALL iom_put( "psiu_mle", zpsi_uw )    ! i-mle streamfunction
+         CALL iom_put( "psiv_mle", zpsi_vw )    ! j-mle streamfunction
+      ENDIF
+      CALL wrk_dealloc( jpi, jpj, zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_NH, zLf_MH)
+      CALL wrk_dealloc( jpi, jpj, jpk, zpsi_uw, zpsi_vw)
+      CALL wrk_dealloc( jpi, jpj, inml_mle)
+
+      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_mle')
+      !
+   END SUBROUTINE tra_adv_mle
+
+
+   SUBROUTINE tra_adv_mle_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_mle_init  ***
+      !!
+      !! ** Purpose :   Control the consistency between namelist options for
+      !!              tracer advection schemes and set nadv
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ierr
+      REAL(wp) ::   z1_t2, zfu, zfv                                !    -         -
+      !
+      NAMELIST/namtra_adv_mle/ ln_mle , nn_mle, rn_ce, rn_lf, rn_time, rn_lat, nn_mld_uv, nn_conv, rn_rho_c_mle
+      !!----------------------------------------------------------------------
+
+      REWIND ( numnam )                ! Read Namelist namtra_adv_mle : mixed layer eddy advection acting on tracers
+      READ   ( numnam, namtra_adv_mle )
+
+      IF(lwp) THEN                     ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_adv_mle_init : mixed layer eddy (MLE) advection acting on tracers'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtra_adv_mle : mixed layer eddy advection on tracers'
+         WRITE(numout,*) '      use mixed layer eddy (MLE, i.e. Fox-Kemper param) (T/F)      ln_mle    = ', ln_mle
+         WRITE(numout,*) '      MLE type: =0 standard Fox-Kemper ; =1 new formulation        nn_mle    = ', nn_mle
+         WRITE(numout,*) '      magnitude of the MLE (typical value: 0.06 to 0.08)           rn_ce     = ', rn_ce
+         WRITE(numout,*) '      scale of ML front (ML radius of deformation) (rn_mle=0)      rn_lf     = ', rn_lf, 'm'
+         WRITE(numout,*) '      maximum time scale of MLE                    (rn_mle=0)      rn_time   = ', rn_time, 's'
+         WRITE(numout,*) '      reference latitude (degrees) of MLE coef.    (rn_mle=1)      rn_lat    = ', rn_lat, 'deg'
+         WRITE(numout,*) '      space interp. of MLD at u-(v-)pts (0=min,1=averaged,2=max)   nn_mld_uv = ', nn_mld_uv
+         WRITE(numout,*) '      =1 no MLE in case of convection ; =0 always MLE              nn_conv   = ', nn_conv
+         WRITE(numout,*) '      Density difference used to define ML for FK              rn_rho_c_mle  = ', rn_rho_c_mle
+      ENDIF
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( ln_mle ) THEN
+            WRITE(numout,*) '   Mixed Layer Eddy induced transport added to tracer advection'
+            IF( nn_mle == 0 )   WRITE(numout,*) '   Fox-Kemper et al 2010 formulation'
+            IF( nn_mle == 1 )   WRITE(numout,*) '   New formulation'
+         ELSE
+            WRITE(numout,*) '   Mixed Layer Eddy parametrisation NOT used'
+         ENDIF
+      ENDIF
+      !
+      IF( ln_mle ) THEN                ! MLE initialisation
+         !
+         rb_c = grav * rn_rho_c_mle /rau0        ! Mixed Layer buoyancy criteria
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '      ML buoyancy criteria = ', rb_c, ' m/s2 '
+         IF(lwp) WRITE(numout,*) '      associated ML density criteria defined in zdfmxl = ', rho_c, 'kg/m3'
+         !
+         IF( nn_mle == 0 ) THEN           ! MLE array allocation & initialisation
+            ALLOCATE( rfu(jpi,jpj) , rfv(jpi,jpj) , STAT= ierr )
+            IF( ierr /= 0 )   CALL ctl_stop( 'tra_adv_mle_init: failed to allocate arrays' )
+            z1_t2 = 1._wp / ( rn_time * rn_time )
+            DO jj = 2, jpj                           ! "coriolis+ time^-1" at u- & v-points
+               DO ji = fs_2, jpi   ! vector opt.
+                  zfu = ( ff(ji,jj) + ff(ji,jj-1) ) * 0.5_wp
+                  zfv = ( ff(ji,jj) + ff(ji-1,jj) ) * 0.5_wp
+                  rfu(ji,jj) = SQRT(  zfu * zfu + z1_t2 )
+                  rfv(ji,jj) = SQRT(  zfv * zfv + z1_t2 )
+               END DO
+            END DO
+            CALL lbc_lnk( rfu, 'U', 1. )   ;   CALL lbc_lnk( rfv, 'V', 1. )
+            !
+         ELSEIF( nn_mle == 1 ) THEN           ! MLE array allocation & initialisation
+            rc_f = rn_ce / (  5.e3_wp * 2._wp * omega * SIN( rad * rn_lat )  )
+            !
+         ENDIF
+         !
+         !                                ! 1/(f^2+tau^2)^1/2 at t-point (needed in both nn_mle case)
+         ALLOCATE( r1_ft(jpi,jpj) , STAT= ierr )
+         IF( ierr /= 0 )   CALL ctl_stop( 'tra_adv_mle_init: failed to allocate r1_ft array' )
+         !
+         z1_t2 = 1._wp / ( rn_time * rn_time )
+         r1_ft(:,:) = 2._wp * omega * SIN( rad * gphit(:,:) )
+         r1_ft(:,:) = 1._wp / SQRT(  r1_ft(:,:) * r1_ft(:,:) + z1_t2 )
+         !
+      ENDIF
+      !
+   END SUBROUTINE tra_adv_mle_init
+
+   !!==============================================================================
+END MODULE traadv_mle
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 4233)
@@ -24,4 +24,7 @@
 
    PUBLIC   zdf_mxl       ! called by step.F90
+
+   REAL(wp), PUBLIC ::   rho_c = 0.01_wp    ! density criterion for mixed layer depth
+   REAL(wp), PUBLIC ::   avt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
 
    INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   nmln    !: number of level in the mixed layer (used by TOP)
@@ -63,5 +66,5 @@
       !! ** Method  :   The mixed layer depth is the shallowest W depth with 
       !!      the density of the corresponding T point (just bellow) bellow a
-      !!      given value defined locally as rho(10m) + zrho_c
+      !!      given value defined locally as rho(10m) + rho_c
       !!               The turbocline depth is the depth at which the vertical
       !!      eddy diffusivity coefficient (resulting from the vertical physics
@@ -76,6 +79,4 @@
       INTEGER  ::   iikn, iiki          ! temporary integer within a do loop
       INTEGER, POINTER, DIMENSION(:,:) ::   imld                ! temporary workspace
-      REAL(wp) ::   zrho_c = 0.01_wp    ! density criterion for mixed layer depth
-      REAL(wp) ::   zavt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
       !!----------------------------------------------------------------------
       !
@@ -98,6 +99,6 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + zrho_c )   nmln(ji,jj) = jk      ! Mixed layer
-               IF( avt (ji,jj,jk) < zavt_c                     )   imld(ji,jj) = jk      ! Turbocline 
+               IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + rho_c )   nmln(ji,jj) = jk      ! Mixed layer
+               IF( avt (ji,jj,jk) < avt_c                     )   imld(ji,jj) = jk      ! Turbocline 
             END DO
          END DO
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/all_functions.sh
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/all_functions.sh	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/all_functions.sh	(revision 4233)
@@ -96,5 +96,5 @@
 	if [ ${#} -lt ${minargcount} ]
 	then
-		echo "not enought arguments for set_namelist"
+		echo "not enough arguments for set_namelist"
 		echo "${usage}"
 		exit 1
@@ -113,5 +113,5 @@
 		echo "doing \"set_namelist $@\". "
 		echo "variable: \"$2\" is empty"
-		echo "control that variable $2 is in \"${EXE_DIR}/$1\" "
+		echo "confirm that variable $2 is in \"${EXE_DIR}/$1\" "
 		echo "exit"
 		echo "error in executing script : set_namelist $@" >> ${SETTE_DIR}/output.sette
@@ -128,4 +128,5 @@
         echo "                " >> ${SETTE_DIR}/output.sette
 }
+
 
 # function to tidy up after each test and populate the NEMO_VALIDATION store
@@ -216,2 +217,148 @@
     fi
 }
+
+#############################################################
+# extra functions to manipulate settings in the iodef.xml file
+#
+# Examples:
+#   set_xio_file_type    iodef.xml one_file
+#   set_xio_using_server iodef.xml true
+#   set_xio_buffer_size  iodef.xml 50000000
+#
+#############################################################
+
+usage2=" Usage : set_xio_file_type input_iodef.xml one_file||multiple_file"
+usage3=" Usage : set_xio_using_server input_iodef.xml true||false"
+usage4=" Usage : set_xio_buffer_size input_iodef.xml int_buffer_size"
+
+set_xio_file_type () {
+        minargcount=2
+        if [ ${#} -lt ${minargcount} ]
+        then
+                echo "not enough arguments for set_xio_file_type"
+                echo "${usage2}"
+                exit 1
+        fi
+        if [ $2 != "one_file" ] && [ $2 != "multiple_file" ]
+        then
+                echo "unrecognised argument for set_xio_file_type"
+                echo "${usage2}"
+                echo $2
+                exit 1
+        fi
+        unset minargcount
+        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
+                touch ${SETTE_DIR}/output.sette
+        fi
+
+        echo "executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
+        echo "################" >> ${SETTE_DIR}/output.sette
+
+        VAR_NAME=$( grep "^.*<.*file_definition.*type.*=" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
+        if [ ${#VAR_NAME} -eq 0 ]
+        then
+                echo "doing \"set_xio_file_type $@\". "
+                echo "xml_tag: file_definition with variable: type is empty"
+                echo "confirm that an appropriate file_definition is in \"${EXE_DIR}/$1\" "
+                echo "exit"
+                echo "error in executing script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
+                echo "....." >> ${SETTE_DIR}/output.sette
+                exit 1
+        fi
+        if [ $2 == "one_file" ] 
+        then
+           sed -e "s:multiple_file:one_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
+        else
+           sed -e "s:one_file:multiple_file:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
+        fi
+        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
+
+        echo "finished script : set_xio_file_type $@" >> ${SETTE_DIR}/output.sette
+        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
+        echo "                " >> ${SETTE_DIR}/output.sette
+}
+
+set_xio_using_server () {
+        minargcount=2
+        if [ ${#} -lt ${minargcount} ]
+        then
+                echo "not enough arguments for set_xio_using_server"
+                echo "${usage2}"
+                exit 1
+        fi
+        if [ $2 != "true" ] && [ $2 != "false" ]
+        then
+                echo "unrecognised argument for set_xio_using_server"
+                echo "${usage2}"
+                echo $2
+                exit 1
+        fi
+        unset minargcount
+        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
+                touch ${SETTE_DIR}/output.sette
+        fi
+
+        echo "executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
+        echo "################" >> ${SETTE_DIR}/output.sette
+
+        VAR_NAME=$( grep "^.*<.*variable id.*=.*using_server.*=.*boolean" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
+        if [ ${#VAR_NAME} -eq 0 ]
+        then
+                echo "doing \"set_xio_using_server $@\". "
+                echo "xml_tag: "variable id=using_server" with variable: boolean is empty"
+                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
+                echo "exit"
+                echo "error in executing script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
+                echo "....." >> ${SETTE_DIR}/output.sette
+                exit 1
+        fi
+        if [ $2 == "false" ]
+        then
+           sed -e "/using_server/s:true:false:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
+           export USING_MPMD=no
+        else
+           sed -e "/using_server/s:false:true:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
+           export USING_MPMD=yes
+        fi
+        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
+
+        echo "finished script : set_xio_using_server $@" >> ${SETTE_DIR}/output.sette
+        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
+        echo "                " >> ${SETTE_DIR}/output.sette
+}
+
+set_xio_buffer_size () {
+        minargcount=2
+        if [ ${#} -lt ${minargcount} ]
+        then
+                echo "not enough arguments for set_xio_buffer_size"
+                echo "${usage4}"
+                exit 1
+        fi
+        unset minargcount
+        if [  ! -f ${SETTE_DIR}/output.sette ] ; then
+                touch ${SETTE_DIR}/output.sette
+        fi
+
+        echo "executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
+        echo "################" >> ${SETTE_DIR}/output.sette
+
+        VAR_NAME=$( grep "^.*<.*variable id.*=.*buffer_size.*=.*integer" ${EXE_DIR}/$1 | sed -e "s% *\!.*%%" )
+        if [ ${#VAR_NAME} -eq 0 ]
+        then
+                echo "doing \"set_xio_buffer_size $@\". "
+                echo "xml_tag: "variable id=buffer_size" with variable: integer is empty"
+                echo "confirm that an appropriate variable id is in \"${EXE_DIR}/$1\" "
+                echo "exit"
+                echo "error in executing script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
+                echo "....." >> ${SETTE_DIR}/output.sette
+                exit 1
+        fi
+        sed -e "/buffer_size/s:>.*<:>$2<:" ${EXE_DIR}/$1 > ${EXE_DIR}/$1.tmp
+        mv ${EXE_DIR}/$1.tmp ${EXE_DIR}/$1
+
+        echo "finished script : set_xio_buffer_size $@" >> ${SETTE_DIR}/output.sette
+        echo "++++++++++++++++" >> ${SETTE_DIR}/output.sette
+        echo "                " >> ${SETTE_DIR}/output.sette
+}
+
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/prepare_job.sh
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/prepare_job.sh	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/prepare_job.sh	(revision 4233)
@@ -68,9 +68,9 @@
 #
 
-usage=" Usage : ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG JOB_FILE"
-usage=" example : ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg 8 SHORT no/yes $JOB_FILE"
-
-
-minargcount=5
+usage=" Usage : ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG JOB_FILE NUM_XIO_SERVERS"
+usage=" example : ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg 8 SHORT no/yes $JOB_FILE 0"
+
+
+minargcount=6
         if [ ${#} -lt ${minargcount} ]
         then
@@ -93,4 +93,5 @@
 MPI_FLAG=$4
 JOB_FILE=$5
+NXIO_PROC=$6
 
 # export EXE_DIR. This directory is used to execute model 
@@ -185,9 +186,9 @@
 		case ${COMPILER} in 
 			ALTIX_NAUTILUS_MPT)
-                                NB_REM=$( echo $NB_PROC | awk '{print $1 % 4}')
+                                NB_REM=$( echo $NB_PROC $NXIO_PROC | awk '{print ( $1 + $2 ) % 4}')
 		        	if [ ${NB_REM} == 0 ] ; then
 					# number of processes required is an integer multiple of 4
 					#
-					NB_NODES=$( echo $NB_PROC | awk '{print $1 / 4}')
+					NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{print ($1 + $2 ) / 4}')
 				else
 					#
@@ -195,5 +196,5 @@
 					# round up the number of nodes required.
 					#
-					NB_NODES=$( echo $NB_PROC | awk '{printf("%d",$1 / 4 + 1 )}')
+					NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{printf("%d",($1 + $2 ) / 4 + 1 )}')
 	       			fi
 				;;
@@ -229,5 +230,7 @@
 # Pass settings into job file by using sed to edit predefined strings
 #
-        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" -e"s/NPROCS/${NB_PROC}/" \
+        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" \
+             -e"s/NPROCS/${NB_PROC}/" \
+             -e"s/NXIOPROCS/${NXIO_PROC}/" \
              -e"s:DEF_SETTE_DIR:${SETTE_DIR}:" -e"s:DEF_INPUT_DIR:${INPUT_DIR}:" \
              -e"s:DEF_EXE_DIR:${EXE_DIR}:" \
Index: branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/sette.sh
===================================================================
--- branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/sette.sh	(revision 4232)
+++ branches/2013/dev_MERCATOR_UKMO_2013/NEMOGCM/SETTE/sette.sh	(revision 4233)
@@ -2,5 +2,6 @@
 ############################################################
 # Author : Simona Flavoni for NEMO
-# Contact : sflod@locean-ipsl.upmc.fr
+# Contact: sflod@locean-ipsl.upmc.fr
+# 2013   : A.C. Coward added options for testing with XIOS in dettached mode
 #
 # sette.sh   : principal script of SET TEsts for NEMO (SETTE)
@@ -15,21 +16,5 @@
 #set -u
 #set -e
-#+
-#
-# ================
-# sette.sh
-# ================
-#
-# ----------------------------------------------
-# Set of tests for NEMO
-# ----------------------------------------------
-#
-# SYNOPSIS
-# ========
-#
-# ::
-#
-#  $ ./sette.sh
-#
+# ===========
 # DESCRIPTION
 # ===========
@@ -37,97 +22,69 @@
 # Variables to be checked by user:
 #
-# COMPILER : name of compiler as defined in NEMOGCM/ARCH directory 
-#
-# BATCH_COMMAND :  name of the command for batch submission
-#
-# INTERACT_FLAG :  flag to run in interactive mode "yes"
-#                       to run in batch mode "no"
-#
-# MPIRUN_FLAG   :  flag to run in parallel (MPI) "yes"
-#                       to run in sequential mode (NB_PROC = 1) "no"
+# COMPILER          : name of compiler as defined in NEMOGCM/ARCH directory 
+# BATCH_COMMAND_PAR :  name of the command for submitting parallel batch jobs
+# BATCH_COMMAND_SEQ :  name of the command for submitting sequential batch jobs  
+# INTERACT_FLAG     : flag to run in interactive mode "yes"
+#                           to run in batch mode "no"
+# MPIRUN_FLAG       : flag to run in parallel (MPI) "yes"
+#                           to run in sequential mode (NB_PROC = 1) "no"
+# USING_XIOS        : flag to control the activation of key_iomput
+#                      "yes" to compile using key_iomput and link to the external XIOS library
+#                      "no"  to compile without key_iomput and link to the old IOIPSL library
+# USING_MPMD        : flag to control the use of stand-alone IO servers
+#                     requires USING_XIOS="yes"
+#                      "yes" to run in MPMD (detached) mode with stand-alone IO servers
+#                      "no"  to run in SPMD (attached) mode without separate IO servers 
+# NUM_XIOSERVERS    : number of stand-alone IO servers to employ
+#                     set to zero if USING_MPMD="no"
 #
 # Principal script is sette.sh, that calls 
 #
-#  makenemo 
-#
-#   creates the exectuable in ${CONFIG_NAME}/BLD/bin/nemo.exe  (and its link opa in ${CONFIG_NAME}/EXP00)
+#  makenemo  : to create successive exectuables in ${CONFIG_NAME}/BLD/bin/nemo.exe 
+#              and links to opa in ${CONFIG_NAME}/EXP00)
 #
 #  param.cfg : sets and loads following directories:
 #
-#   FORCING_DIR : is the directory for forcing files (tarfile)
-#
-#   INPUT_DIR : is the directory for input files storing 
-#
-#   TMPDIR : is the temporary directory (if needed)
+#   FORCING_DIR         : is the directory for forcing files (tarfile)
+#   INPUT_DIR           : is the directory for input files storing 
+#   TMPDIR              : is the temporary directory (if needed)
+#   NEMO_VALIDATION_DIR : is the validation directory
+#
+#   (NOTE: this file is the same for all configrations to be tested with sette)
+#
+#   all_functions.sh : loads functions used by sette (note: new functions can be added here)
+#   set_namelist     : function declared in all_functions that sets namelist parameters 
+#   post_test_tidyup : creates validation storage directory and copies required output files 
+#                      (solver.stat and ocean.output) in it after execution of test.
+#
+#  VALIDATION tree is:
+#
+#   NEMO_VALIDATION_DIR/WCONFIG_NAME/WCOMPILER_NAME/TEST_NAME/REVISION_NUMBER(or DATE)
+#
+#  prepare_exe_dir.sh : defines and creates directory where the test is executed
+#                       execution directory takes name of TEST_NAME defined for every test 
+#                       in sette.sh. (each test in executed in its own directory)
+#
+#  prepare_job.sh     : to generate the script run_job.sh
+#
+#  fcm_job.sh         : run in batch (INTERACT_FLAG="no") or interactive (INTERACT_FLAG="yes")
+#                        see sette.sh and BATCH_TEMPLATE directory
+#
+#  NOTE: jobs requiring initial or forcing data need to have an input_CONFIG.cfg in which 
+#        can be found paths to the input tar file)
+#  NOTE: if job is not launched for any reason you have the executable ready in ${EXE_DIR} 
+#        directory
+#  NOTE: the changed namelists are left in ${EXE_DIR} directory whereas original namelists 
+#        remain in ${NEW_CONF}/EXP00
 # 
-#   NEMO_VALIDATION_DIR : is the validation directory
-#
-#   (NOTE: this file is the same for all configrations to be tested with sette)
-#
-#
-#  all_functions.sh : loads functions used by sette (note: new functions can be added here)
-#
-#   set_namelist : function declared in all_functions that set namelist parameters for tests
-#
-#   post_test_tidyup : creates validation storage directory and copy needed output files (solver.stat and ocean.output) in it after execution of test.
-#
-#   Tree of VALIDATION is:
-#
-#   NEMO_VALIDATION_DIR/WCONFIG_NAME/WCOMPILER_NAME/TEST_NAME/REVISION_NUMBER(or DATE)
-#
-#
-#  prepare_exe_dir.sh : defines and creates directory where the test is executed
-#
-#       execution directory takes name of TEST_NAME defined in every test in sette.sh
-#
-#       ( each test in executed in its own directory )
-#
-#
-#  prepare_job.sh
-#
-#  to generate the script run_job.sh
-#
-#  fcm_job.sh 
-#
-#   run in batch (INTERACT_FLAG="no") or interactive (INTERACT_FLAG="yes") see sette.sh and BATCH_TEMPLATE directory
-#
-#   (note this job needs to have an input_CONFIG.cfg in which can be found input tar file)
-# 
-#  NOTE: if job is not launched for some problems you have executable ready in ${EXE_DIR} directory
-#
-#  NOTE: the changed namelists are leaved in ${EXE_DIR} directory whereas original namelist remains in ${NEW_CONF}/EXP00
-# 
-#  in ${SETTE_DIR} is created output.sette with the echo of executed commands
-#
-#  if sette.sh is stopped in output.sette there is written the last command executed by sette.sh
-#
-#  if you run: ./sette.sh 2>&1 | tee out.sette
-#
-#  in ${SETTE_DIR} out.sette is redirected standard error & standard output
-#
-#
-# EXAMPLES
-# ========
-#
-# ::
-#
-#  $ ./sette.sh 
-#
-#
-# TODO
-# ====
-#
-# option debug
-#
-# EVOLUTIONS
-# ==========
-#
-# $Id$
-#
-#   * creation
-#
-#-
-#
-#-
+#  NOTE: a log file, output.sette, is created in ${SETTE_DIR} with the echoes of 
+#        executed commands
+#
+#  NOTE: if sette.sh is stopped in output.sette there is written the last command 
+#        executed by sette.sh
+#
+# example use: ./sette.sh 
+#########################################################################################
+#
 # Compiler among those in NEMOGCM/ARCH
 COMPILER=PW6_VARGAS
@@ -136,9 +93,31 @@
 export INTERACT_FLAG="no"
 export MPIRUN_FLAG="yes"
-# IF YOU DON'T WANT TO USE XIOS : (this is a list of keys to be delete)
-export KEY_XIOS="key_iomput"
-# IF YOU WANT TO USE XIOS :
-#export KEY_XIOS=""
-
+export USING_XIOS="yes"
+#
+export DEL_KEYS="key_iomput"
+if [ ${USING_XIOS} == "yes" ] 
+ then 
+   export DEL_KEYS=""
+fi
+#
+# Settings which control the use of stand alone servers (only relevant if using xios)
+#
+export USING_MPMD="no"
+export NUM_XIOSERVERS=4
+export JOB_PREFIX=batch-mpmd
+#
+if [ ${USING_MPMD} == "no" ] 
+ then
+   export NUM_XIOSERVERS=0
+   export JOB_PREFIX=batch
+fi
+#
+#
+if [ ${USING_MPMD} == "yes" ] && [ ${USING_XIOS} == "no"]
+ then
+   echo "Incompatible choices. MPMD mode requires the XIOS server"
+   exit
+fi
+#
 
 # Directory to run the tests
@@ -152,5 +131,5 @@
 # Copy job_batch_COMPILER file for specific compiler into job_batch_template
 cd ${SETTE_DIR}
-cp BATCH_TEMPLATE/batch-${COMPILER} job_batch_template || exit
+cp BATCH_TEMPLATE/${JOB_PREFIX}-${COMPILER} job_batch_template || exit
 
 for config in 1 2 3 4 5 6 7 8 9
@@ -162,5 +141,5 @@
     export TEST_NAME="LONG"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_LONG -r GYRE -j 8 add_key "key_mpp_mpi" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_LONG -r GYRE -j 8 add_key "key_mpp_mpi" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -169,5 +148,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=4
-    \rm ${JOB_FILE}
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"GYRE_LONG\"
@@ -180,6 +159,11 @@
     set_namelist namelist jpnj 2
     set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
 
     cd ${SETTE_DIR}
@@ -199,4 +183,9 @@
     set_namelist namelist jpnij 4
     set_namelist namelist cn_ocerst_in \"GYRE_LONG_00000060_restart\"
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
     for (( i=1; i<=$NPROC; i++)) ; do
         L_NPROC=$(( $i - 1 ))
@@ -204,6 +193,11 @@
         ln -sf ../LONG/GYRE_LONG_00000060_restart_${L_NPROC}.nc .
     done
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -214,5 +208,5 @@
     export TEST_NAME="REPRO_1_4"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_4 -r GYRE -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n GYRE_4 -r GYRE -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -221,5 +215,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=4
-    \rm ${JOB_FILE}
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"GYRE_14\"
@@ -234,6 +228,11 @@
     set_namelist namelist jpnj 4
     set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -244,5 +243,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=4
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"GYRE_22\"
@@ -256,6 +255,11 @@
     set_namelist namelist jpnj 2
     set_namelist namelist jpnij 4
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_GYRE.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -268,5 +272,5 @@
     export TEST_NAME="LONG"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_LONG -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_mpi" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_LONG -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_mpi" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -275,5 +279,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=4
-    \rm ${JOB_FILE}
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"O2LP_LONG\"
@@ -298,6 +302,11 @@
     set_namelist namelist_pisces ln_ironsed .false.
     set_namelist namelist_pisces ln_hydrofe .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     
     cd ${SETTE_DIR}
@@ -341,6 +350,11 @@
         ln -sf ../LONG/O2LP_LONG_00000075_restart_ice_${L_NPROC}.nc .
     done
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -351,5 +365,5 @@
     export TEST_NAME="REPRO_4_4"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_16 -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2LIMPIS_16 -r ORCA2_LIM_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -358,5 +372,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=16
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -383,6 +397,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -393,5 +412,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=16
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -417,6 +436,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -428,5 +452,5 @@
     export TEST_NAME="LONG"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_LONG -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_LONG -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -435,5 +459,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=4
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist cn_exp \"OFFP_LONG\"
@@ -459,6 +483,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     
     cd ${SETTE_DIR}
@@ -495,6 +524,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME}  ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME}  ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -505,5 +539,5 @@
     export TEST_NAME="REPRO_4_4"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_16 -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2OFFPIS_16 -r ORCA2_OFF_PISCES -j 8 add_key "key_mpp_mpi key_mpp_rep" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -512,5 +546,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=16
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -535,6 +569,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -545,5 +584,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=16
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -568,6 +607,11 @@
     # put ln_pisdmp to false : no restoring to global mean value
     set_namelist namelist_pisces ln_pisdmp .false. 
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_OFF_PISCES.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC  ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -579,5 +623,5 @@
     export TEST_NAME="LONG"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_LONG -r AMM12 -j 8 add_key "key_tide" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_LONG -r AMM12 -j 8 add_key "key_tide" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -586,5 +630,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=32
-    \rm $JOB_FILE
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -600,6 +644,11 @@
     set_namelist namelist jpnj 4
     set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
 
     cd ${SETTE_DIR}
@@ -625,6 +674,11 @@
         ln -sf ../LONG/AMM12_00000006_restart_${L_NPROC}.nc .
     done
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -635,5 +689,5 @@
     export TEST_NAME="REPRO_8_4"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_32 -r AMM12 -j 8 add_key "key_mpp_rep key_tide" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n AMM12_32 -r AMM12 -j 8 add_key "key_mpp_rep key_tide" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -642,5 +696,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=32
-    \rm ${JOB_FILE}
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -655,6 +709,11 @@
     set_namelist namelist jpnj 4
     set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -675,6 +734,11 @@
     set_namelist namelist jpnj 8
     set_namelist namelist jpnij 32
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_AMM12.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
@@ -686,5 +750,5 @@
     export TEST_NAME="SHORT"
     cd ${SETTE_DIR}
-    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2AGUL_1_2 -r ORCA2_LIM -j 8 add_key "key_mpp_mpi key_mpp_rep key_agrif" del_key "key_zdftmx" del_key ${KEY_XIOS}
+    . ../CONFIG/makenemo -m ${CMP_NAM} -n ORCA2AGUL_1_2 -r ORCA2_LIM -j 8 add_key "key_mpp_mpi key_mpp_rep key_agrif" del_key "key_zdftmx" del_key ${DEL_KEYS}
     cd ${SETTE_DIR}
     . param.cfg
@@ -693,5 +757,5 @@
     JOB_FILE=${EXE_DIR}/run_job.sh
     NPROC=2
-    \rm ${JOB_FILE}
+    if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
     set_namelist namelist nn_it000 1
@@ -706,6 +770,11 @@
     set_namelist 1_namelist ln_ctl .false.
     set_namelist 1_namelist ln_clobber .true.
-    cd ${SETTE_DIR}
-    . ./prepare_job.sh input_ORCA2_LIM_AGRIF.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE}
+    if [ ${USING_MPMD} == "yes" ] ; then
+       set_xio_using_server iodef.xml true
+    else
+       set_xio_using_server iodef.xml false
+    fi
+    cd ${SETTE_DIR}
+    . ./prepare_job.sh input_ORCA2_LIM_AGRIF.cfg $NPROC ${TEST_NAME} ${MPIRUN_FLAG} ${JOB_FILE} ${NUM_XIOSERVERS}
     cd ${SETTE_DIR}
     . ./fcm_job.sh $NPROC ${JOB_FILE} ${INTERACT_FLAG} ${MPIRUN_FLAG}
