Index: /utils/build/mk/agrifpp.sh
===================================================================
--- /utils/build/mk/agrifpp.sh	(revision 13054)
+++ /utils/build/mk/agrifpp.sh	(revision 13055)
@@ -55,8 +55,13 @@
 #
 #-
-MYFILE=$(basename "$1")
+MYDIR=$1
+MYFILE=$(basename "$2")
 if [ "$MYFILE" == "agrif2model.f90" ];then
-   \cp ${NEMO_TDIR}/${NEW_CONF}/WORK/${MYFILE/.f90/.F90} ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/obj/$MYFILE
+   if [ -d ${MYDIR}/${NEW_CONF}/WORK ]; then
+      \cp ${MYDIR}/${NEW_CONF}/WORK/${MYFILE/.f90/.F90} ${MYDIR}/${NEW_CONF}/NEMOFILES/obj/$MYFILE
+   else
+      \cp ${MYDIR}/${NEW_CONF}/src/${MYFILE/.f90/.F90} ${MYDIR}/${NEW_CONF}/NEMOFILES/obj/$MYFILE
+   fi   
 else
-cd ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/ppsrc/nemo ; ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/conv ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/agrif_oce.in -rm -incdir ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/inc -comdirout ${NEMO_TDIR}/${NEW_CONF}/NEMOFILES/obj -convfile ${MYFILE} > /dev/null 
+cd ${MYDIR}/${NEW_CONF}/NEMOFILES/ppsrc/nemo ; ${MYDIR}/${NEW_CONF}/NEMOFILES/conv ${MYDIR}/${NEW_CONF}/NEMOFILES/agrif_oce.in -rm -incdir ${MYDIR}/${NEW_CONF}/NEMOFILES/inc -comdirout ${MYDIR}/${NEW_CONF}/NEMOFILES/obj -convfile ${MYFILE} > /dev/null 
 fi
Index: /utils/build/mk/bld_preproagr.cfg
===================================================================
--- /utils/build/mk/bld_preproagr.cfg	(revision 13054)
+++ /utils/build/mk/bld_preproagr.cfg	(revision 13055)
@@ -21,5 +21,5 @@
 bld::tool::fc_compile
 bld::tool::fc_include
-bld::tool::fc        $COMPIL_DIR/agrifpp.sh 
+bld::tool::fc        $COMPIL_DIR/agrifpp.sh ${NEMO_TDIR}
 bld::tool::fflags    
 bld::tool::ld       
Index: /utils/build/mk/bld_preproagr_tools.cfg
===================================================================
--- /utils/build/mk/bld_preproagr_tools.cfg	(revision 13055)
+++ /utils/build/mk/bld_preproagr_tools.cfg	(revision 13055)
@@ -0,0 +1,81 @@
+# ----------------------- FCM extract configuration file -----------------------
+cfg::type                           bld
+cfg::version                        1.0
+
+
+# ------------------------------------------------------------------------------
+# Build information
+# ------------------------------------------------------------------------------
+
+inc $COMPIL_DIR/arch_tools.fcm
+inc $COMPIL_DIR/cpp_tools.fcm
+search_src           1
+
+src::nemo                 $TOOLS_DIR/$NEW_CONF/src
+
+bld::target  make_domain_cfg.f90 agrif_user.f90 agrif2model.f90 
+
+dir::root            $TOOLS_DIR/$NEW_CONF/NEMOFILES
+
+bld::tool::fc_output
+bld::tool::fc_compile
+bld::tool::fc_include
+bld::tool::fc        $COMPIL_DIR/agrifpp.sh $TOOLS_DIR
+bld::tool::fflags    
+bld::tool::ld       
+bld::tool::ldflags   
+bld::tool::ar        
+bld::tool::arflags   
+bld::tool::make      %MK
+
+OUTFILE_EXT::obj   .f90
+
+# Pre-process code before analysing dependencies
+bld::pp::nemo     1
+bld::pp::nemo/agrif2model     0
+bld::tool::cpp       %CPP
+bld::tool::fpp       %CPP
+bld::tool::fppflags::nemo  %FPPFLAGS
+
+# Ignore the following dependencies
+bld::excl_dep        inc::netcdf.inc
+bld::excl_dep        inc::VT.inc
+bld::excl_dep        use::netcdf
+bld::excl_dep        h::netcdf.inc
+bld::excl_dep        h::mpif.h
+bld::excl_dep        inc::mpif.h
+bld::excl_dep        inc::mpe_logf.h
+bld::excl_dep        use::mpi
+bld::excl_dep        use::mod_oasis
+bld::excl_dep        use::mkl_dfti
+#bld::excl_dep	     use::ioipsl
+bld::excl_dep	     use::xios
+bld::excl_dep        use::agrif_grids
+bld::excl_dep	     use::agrif_types
+bld::excl_dep	     use::agrif_util
+bld::excl_dep        inc::SetNumberofcells.h
+bld::excl_dep        inc::GetNumberofcells.h
+bld::excl_dep        inc::include_use_Alloc_agrif.h
+bld::excl_dep        inc::allocations_calls_agrif.h
+bld::excl_dep        inc::modtype_agrif.h
+bld::excl_dep        inc::probdim_agrif.h
+bld::excl_dep        inc::keys_agrif.h
+bld::excl_dep        h::SetNumberofcells.h
+bld::excl_dep        h::GetNumberofcells.h
+bld::excl_dep        h::include_use_Alloc_agrif.h
+bld::excl_dep        h::allocations_calls_agrif.h
+bld::excl_dep        h::modtype_agrif.h
+bld::excl_dep        h::probdim_agrif.h
+bld::excl_dep        h::keys_agrif.h
+bld::excl_dep        use::mod_attribut
+bld::excl_dep        use::mod_event_client
+bld::excl_dep        use::mod_ioclient
+#bld::excl_dep        OBJ
+
+# Don't generate interface files
+bld::tool::geninterface none
+
+# Allow ".h90" and ".f90" as an extension for CPP include files
+bld::infile_ext::h90  CPP::INCLUDE
+bld::infile_ext::f90  FPP::FPP9X::SOURCE
+bld::src_type::nemo/agrif2model.F90 FORTRAN::FORTRAN9X::SOURCE
Index: /utils/build/mk/bld_tools.cfg
===================================================================
--- /utils/build/mk/bld_tools.cfg	(revision 13054)
+++ /utils/build/mk/bld_tools.cfg	(revision 13055)
@@ -13,7 +13,14 @@
 search_src           1
 
-src::nemo            $TOOLS_DIR/$NEW_CONF/src
+src::agrif           $MAIN_DIR/ext/AGRIF/AGRIF_FILES
+src::nemo            $TOOLS_DIR/$NEW_CONF/NEMOFILES/obj
+
+
+bld::target  make_domain_cfg.exe
+bld::exe_dep
+
 
 dir::root            $TOOLS_DIR/$NEW_CONF/BLD
+
 
 bld::tool::cpp       %CPP
@@ -29,5 +36,10 @@
 # Pre-process code before analysing dependencies
 bld::pp::nemo     1
+bld::pp::agrif    1
 bld::tool::fppflags::nemo      %FPPFLAGS -I$TOOLS_DIR/$NEW_CONF/NEMOFILES/inc
+bld::tool::fppflags::agrif     %FPPFLAGS -include ${MAIN_DIR}/ext/AGRIF/nemo_mpi.h
+
+
+
 
 # Ignore the following dependencies
@@ -41,4 +53,6 @@
 bld::excl_dep        use::mod_oasis
 
+
+
 # Don't generate interface files
 bld::tool::geninterface none
Index: /utils/build/mk/bldxag_tools.cfg
===================================================================
--- /utils/build/mk/bldxag_tools.cfg	(revision 13055)
+++ /utils/build/mk/bldxag_tools.cfg	(revision 13055)
@@ -0,0 +1,51 @@
+# ----------------------- FCM extract configuration file -----------------------
+cfg::type                           bld
+cfg::version                        1.0
+
+
+# ------------------------------------------------------------------------------
+# Build information
+# ------------------------------------------------------------------------------
+
+inc $COMPIL_DIR/arch_tools.fcm
+inc $COMPIL_DIR/cpp_tools.fcm
+
+search_src           1
+
+src::nemo            $TOOLS_DIR/$NEW_CONF/src
+
+dir::root            $TOOLS_DIR/$NEW_CONF/BLD
+
+bld::tool::cpp       %CPP
+bld::tool::fpp       %CPP
+bld::tool::fc        %FC
+bld::tool::fflags    %FCFLAGS %USER_INC
+bld::tool::ld        %LD
+bld::tool::ldflags   %LDFLAGS %USER_LIB
+bld::tool::ar        %AR
+bld::tool::arflags   %ARFLAGS
+bld::tool::make      %MK
+
+# Pre-process code before analysing dependencies
+bld::pp::nemo     1
+bld::tool::fppflags::nemo      %FPPFLAGS
+
+# Ignore the following dependencies
+bld::excl_dep        inc::netcdf.inc
+bld::excl_dep        use::netcdf
+bld::excl_dep        use::xios
+bld::excl_dep        h::netcdf.inc
+bld::excl_dep        h::mpif.h
+bld::excl_dep        inc::mpif.h
+bld::excl_dep        use::mpi
+bld::excl_dep        use::mod_oasis
+
+# Don't generate interface files
+bld::tool::geninterface none
+
+# Allow ".h90" as an extension for CPP include files
+bld::infile_ext::h90  CPP::INCLUDE
+bld::infile_ext::f90  FPP::FPP9X::SOURCE
+
+# extension for module output
+bld::outfile_ext::mod .mod
Index: /utils/tools_dev_r12970_AGRIF_CMEMS/maketools
===================================================================
--- /utils/tools_dev_r12970_AGRIF_CMEMS/maketools	(revision 13054)
+++ /utils/tools_dev_r12970_AGRIF_CMEMS/maketools	(revision 13055)
@@ -159,4 +159,14 @@
 . ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm cpp_tools.fcm ${CMP_NAM} || exit
 
+#- At this stage the configuration has beeen chosen
+#- We coose the default light file
+export USEBLD=bldxag_tools.cfg
+
+#- We look after agrif
+grep key_agrif ${COMPIL_DIR}/cpp_tools.fcm && export AGRIFUSE=1 && export USEBLD=${USEBLD/xag/}
+
+. ${COMPIL_DIR}/Fprep_agrif.sh ${NEW_CONF} ${TOOLS_DIR} || exit 3
+
+
 #-
 #_ END OF CONFIGURATION PHASE
@@ -167,13 +177,23 @@
 
 if [ "${NBR_PRC}" -gt 0 ]; then
-cd ${NEMO_TDIR}/${NEW_CONF} || cd -
-
-fcm build ${x_c} --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/bld_tools.cfg || cd -
-if [ -n "$(ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe)" ]; then
-for i in `ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe`
-   do
-      ln -sf ${i}  ${TOOLS_DIR}/${NEW_CONF}/.
-   done
-fi
+cd ${TOOLS_DIR}/${NEW_CONF} || cd -
+
+	## if AGRIF we do a first preprocessing
+	if [[ ${#x_c} -eq 0 && "$AGRIFUSE" -eq 1 ]]; then
+		fcm build --ignore-lock -j 1 ${COMPIL_DIR}/bld_preproagr_tools.cfg ||{ cd - ; exit 1 ;}
+		echo ''
+		echo "---------------------------------"
+		echo "CONV preprocessing successfull !!"
+		echo "---------------------------------"
+		echo ''
+	fi
+
+   fcm build ${x_c} --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/${USEBLD} || cd -
+   if [ -n "$(ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe)" ]; then
+      for i in `ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe`
+      do
+         ln -sf ${i}  ${TOOLS_DIR}/${NEW_CONF}/.
+      done
+   fi
 fi
 #-
