Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/CONFIG/makenemo
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/CONFIG/makenemo	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/CONFIG/makenemo	(revision 3390)
@@ -302,6 +302,12 @@
 #if AGRIF we do a first preprocessing
     if [ ${#x_c} -eq 0 ]; then
-        [ "$AGRIFUSE" == 1 ] && fcm build --ignore-lock -s 2 ${COMPIL_DIR}/$USEBLD
-        [ "$AGRIFUSE" == 1 ] && rm -rf  ${NEMO_TDIR}/${NEW_CONF}/BLD/*
+       if [ "$AGRIFUSE" == 1 ]; then 
+          fcm build --ignore-lock  -j 1 ${COMPIL_DIR}/bld_preproagr.cfg ||{ cd - ; exit ;}
+          echo ""
+          echo "---------------------------------"
+          echo "CONV preprocessing successfull !!"
+          echo "---------------------------------"
+          echo ""
+       fi
     fi
     fcm build ${x_c} --ignore-lock -v ${x_v} -j ${NBR_PRC} ${COMPIL_DIR}/$USEBLD || cd -
@@ -311,4 +317,5 @@
 #add remove for clean option
     if  [ ${#x_c} -ne 0 ]; then
+        rm -rf ${NEMO_TDIR}/${NEW_CONF}/OPAFILES
         rm -rf ${NEMO_TDIR}/${NEW_CONF}/WORK
         rm -rf ${NEMO_TDIR}/${NEW_CONF}/BLD
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif2model.F90
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif2model.F90	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif2model.F90	(revision 3390)
@@ -5,4 +5,9 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
+   SUBROUTINE Agrif2Model
+      !!---------------------------------------------
+      !!   *** ROUTINE Agrif2Model ***
+      !!--------------------------------------------- 
+   END SUBROUTINE Agrif2model
 
    SUBROUTINE Agrif_Set_numberofcells(Agrif_Gr)
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 3390)
@@ -5,4 +5,7 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
+   SUBROUTINE agrif_user
+   END SUBROUTINE
+
    SUBROUTINE agrif_before_regridding
    END SUBROUTINE
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/OPA_SRC/lib_cray.f90
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/OPA_SRC/lib_cray.f90	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/NEMO/OPA_SRC/lib_cray.f90	(revision 3390)
@@ -10,4 +10,8 @@
 !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
 !!----------------------------------------------------------------------
+SUBROUTINE lib_cray
+      WRITE(*,*) 'lib_cray: You should not have seen this print! error?'
+END SUBROUTINE lib_cray
+
 SUBROUTINE wheneq ( i, x, j, t, ind, nn )
         IMPLICIT NONE
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/agrifpp.sh
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/agrifpp.sh	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/agrifpp.sh	(revision 3390)
@@ -26,5 +26,9 @@
 #
 #
-# Look after key agrif, if yes the conv is used, otherwise standard pre-processing is performed.
+# Preprocess file using the conv in OPAFILES directory
+# Standard preprocessed files are stored in OPAFILES/ppsrc/nemo
+# Source files are stored under OPAFILES/obj
+# Include filess  in OPAFILES/inc
+# Note that agrif2model.F90 should not be preprocess (standard one) 
 #
 # EXAMPLES
@@ -33,10 +37,6 @@
 # ::
 #
-#  $ ./agrifpp.sh 1 -Dkey
+#  $ ./agrifpp.sh FILE_TO_PROCESS
 # 
-#  or
-#
-#  $ ./agrifpp.sh -Dkey
-#
 # TODO
 # ====
@@ -55,35 +55,8 @@
 #
 #-
-
-if [ "$1" == "1" ]; then
-   shift
-   MYFILE=`echo $* |awk -F" " '{print $NF}' `  
-   FPP_OPT=` echo $* |awk '{  for (i=1 ; i<NF ; i++ )  { printf " %s",  $i } }'`
-
-
-   if [ "${MYFILE}" != "par_oce.F90" -a  ! -f ${NEMO_TDIR}/${NEW_CONF}}/OPAFILES/param_done ]; then
-      cpp ${FPP_OPT} ${CONFIG_DIR}/${NEW_CONF}/WORK/par_oce.F90 > ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/par_oce.F90
-      (cd ${NEMO_TDIR}/${NEW_CONF}/OPAFILES ; ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/conv agrif_opa.in -rm -comdirin ./ -comdirout AGRIF_MODELFILES/ -convfile par_oce.F90 > /dev/null )
-      cpp ${FPP_OPT}  -I${NEMO_TDIR}/${NEW_CONF}/OPAFILES/AGRIF_INC  ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/AGRIF_MODELFILES/par_oce.F90 > ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/par_oce.F90
-      touch ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/param_done
-   elif  [ "${MYFILE}" == "par_oce.F90" -a -f ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/param_done ] ; then
-      cd  ${NEMO_TDIR}/${NEW_CONF}/OPAFILES
-      cpp ${FPP_OPT} -I${NEMO_TDIR}/${NEW_CONF}/OPAFILES/AGRIF_INC ${MYFILE}
-      exit
-   fi
-
-   if [ "${MYFILE}" == agrif2model.F90 ]; then
-      cpp  -I${NEMO_TDIR}/${NEW_CONF}/OPAFILES/AGRIF_INC $@
-      exit
-   fi 
-
-   cpp  -I${NEMO_TDIR}/${NEW_CONF}/OPAFILES/AGRIF_INC $@ > ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/${MYFILE}
-   ( cd ${NEMO_TDIR}/${NEW_CONF}/OPAFILES ; ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/conv agrif_opa.in -rm -comdirin ./ -comdirout AGRIF_MODELFILES/ -convfile ${MYFILE} > /dev/null )
-   cd  ${NEMO_TDIR}/${NEW_CONF}
-   sed 's/[ 	]*$//' OPAFILES/AGRIF_MODELFILES/${MYFILE}> OPAFILES/${MYFILE}
-   cpp ${FPP_OPT} -IOPAFILES/AGRIF_INC OPAFILES/${MYFILE} 
+MYFILE=$(basename "$1")
+if [ "$MYFILE" == "agrif2model.f90" ];then
+   \cp ${NEMO_TDIR}/${NEW_CONF}/WORK/${MYFILE/.f90/.F90} ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/obj/$MYFILE
 else
-   shift
-   cpp $@
+cd ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/ppsrc/nemo ; ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/conv ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/agrif_opa.in -rm -incdir ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/inc -comdirout ${NEMO_TDIR}/${NEW_CONF}/OPAFILES/obj -convfile ${MYFILE} > /dev/null 
 fi
-
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld.cfg
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld.cfg	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld.cfg	(revision 3390)
@@ -23,5 +23,5 @@
 src::ioipsl               $MAIN_DIR/EXTERNAL/IOIPSL/src
 src::agrif                $MAIN_DIR/EXTERNAL/AGRIF/AGRIF_FILES
-src::nemo                 $CONFIG_DIR/$NEW_CONF/WORK
+src::nemo                 $CONFIG_DIR/$NEW_CONF/OPAFILES/obj
 
 #bld::lib::xmlf90           xmlf90
@@ -54,10 +54,9 @@
 bld::pp::nemo     1
 bld::pp::agrif    1
-bld::tool::fpp       $COMPIL_DIR/agrifpp.sh
-bld::tool::fppflags::nemo ${AGRIFUSE} %FPPFLAGS
-bld::tool::fppflags::xmlio    0 %FPPFLAGS
-bld::tool::fppflags::ioserver 0 %FPPFLAGS
-bld::tool::fppflags::ioipsl   0 %FPPFLAGS
-bld::tool::fppflags::agrif    0 %FPPFLAGS
+bld::tool::fppflags::nemo      %FPPFLAGS -I$CONFIG_DIR/$NEW_CONF/OPAFILES/inc
+bld::tool::fppflags::xmlio     %FPPFLAGS
+bld::tool::fppflags::ioserver  %FPPFLAGS
+bld::tool::fppflags::ioipsl    %FPPFLAGS
+bld::tool::fppflags::agrif     %FPPFLAGS
 
 # Ignore the following dependencies
@@ -82,4 +81,5 @@
 # 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
@@ -88,3 +88,2 @@
 # rename executable to nemo.exe
 bld::exe_name::model  nemo.exe
-
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld_preproagr.cfg
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld_preproagr.cfg	(revision 3390)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bld_preproagr.cfg	(revision 3390)
@@ -0,0 +1,81 @@
+# ----------------------- FCM extract configuration file -----------------------
+cfg::type                           bld
+cfg::version                        1.0
+
+
+# ------------------------------------------------------------------------------
+# Build information
+# ------------------------------------------------------------------------------
+
+inc $COMPIL_DIR/arch_nemo.fcm
+inc $COMPIL_DIR/cpp.fcm
+search_src           1
+
+src::nemo                 $CONFIG_DIR/$NEW_CONF/WORK
+
+bld::target  lib_cray.f90 nemo.f90 agrif_user.f90 agrif2model.f90 
+
+dir::root            $NEMO_TDIR/$NEW_CONF/OPAFILES
+
+bld::tool::fc_output
+bld::tool::fc_compile
+bld::tool::fc_include
+bld::tool::fc        $COMPIL_DIR/agrifpp.sh 
+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::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_prism_proto
+bld::excl_dep        use::mod_prism_def_partition_proto
+bld::excl_dep        use::mod_prism_get_comm
+bld::excl_dep        use::mod_prism_get_proto
+bld::excl_dep        use::mod_prism_put_proto
+bld::excl_dep        use::mod_comprism_proto
+bld::excl_dep        use::mkl_dfti
+bld::excl_dep	     use::nc4interface
+bld::excl_dep	     use::ioipsl
+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        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: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxag.cfg
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxag.cfg	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxag.cfg	(revision 3390)
@@ -44,9 +44,8 @@
 bld::pp::ioipsl   1
 bld::pp::nemo     1
-bld::tool::fpp       $COMPIL_DIR/agrifpp.sh
-bld::tool::fppflags::nemo ${AGRIFUSE} %FPPFLAGS
-bld::tool::fppflags::xmlio    0 %FPPFLAGS
-bld::tool::fppflags::ioserver 0 %FPPFLAGS
-bld::tool::fppflags::ioipsl   0 %FPPFLAGS
+bld::tool::fppflags::nemo     %FPPFLAGS
+bld::tool::fppflags::xmlio    %FPPFLAGS
+bld::tool::fppflags::ioserver %FPPFLAGS
+bld::tool::fppflags::ioipsl   %FPPFLAGS
 
 # Ignore the following dependencies
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxio.cfg
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxio.cfg	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxio.cfg	(revision 3390)
@@ -15,12 +15,9 @@
 src::ioipsl               $MAIN_DIR/EXTERNAL/IOIPSL/src
 src::agrif                $MAIN_DIR/EXTERNAL/AGRIF/AGRIF_FILES
-src::nemo                 $CONFIG_DIR/$NEW_CONF/WORK
-
+src::nemo                 $CONFIG_DIR/$NEW_CONF/OPAFILES/obj 
 bld::target  nemo.exe
 bld::exe_dep
 
-
 dir::root            $NEMO_TDIR/$NEW_CONF/BLD
-
 
 bld::tool::fc        %FC 
@@ -37,8 +34,7 @@
 bld::pp::nemo     1
 bld::pp::agrif    1
-bld::tool::fpp       $COMPIL_DIR/agrifpp.sh
-bld::tool::fppflags::nemo ${AGRIFUSE} %FPPFLAGS
-bld::tool::fppflags::ioipsl   0 %FPPFLAGS
-bld::tool::fppflags::agrif    0 %FPPFLAGS
+bld::tool::fppflags::nemo     %FPPFLAGS -I$CONFIG_DIR/$NEW_CONF/OPAFILES/inc
+bld::tool::fppflags::ioipsl   %FPPFLAGS
+bld::tool::fppflags::agrif    %FPPFLAGS
 
 # Ignore the following dependencies
@@ -63,4 +59,5 @@
 # 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
@@ -69,3 +66,2 @@
 # rename executable to nemo.exe
 bld::exe_name::model  nemo.exe
-
Index: /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxioxag.cfg
===================================================================
--- /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxioxag.cfg	(revision 3389)
+++ /branches/2012/dev_r3387_LOCEAN6_AGRIF_LIM/NEMOGCM/TOOLS/COMPILE/bldxioxag.cfg	(revision 3390)
@@ -34,7 +34,6 @@
 bld::pp::ioipsl   1
 bld::pp::nemo     1
-bld::tool::fpp       $COMPIL_DIR/agrifpp.sh
-bld::tool::fppflags::nemo ${AGRIFUSE} %FPPFLAGS
-bld::tool::fppflags::ioipsl   0 %FPPFLAGS
+bld::tool::fppflags::nemo     %FPPFLAGS
+bld::tool::fppflags::ioipsl   %FPPFLAGS
 
 # Ignore the following dependencies
