Index: /trunk/UTIL/fait_AA_make
===================================================================
--- /trunk/UTIL/fait_AA_make	(revision 393)
+++ /trunk/UTIL/fait_AA_make	(revision 394)
@@ -1,42 +1,100 @@
 #!/bin/ksh
-#set -xv
-#-
-echo "This script must be run while in the modipsl/modeles/OPA directory"
+#set -vx
+############################################################
+#
+# Purpose :
+# This script aims to create create the AA_make file
+# in the WORK directory. 
+# AA_make contains :
+#    - compilation options speccific to NEMO
+#    - compilation rules
+#    - dependancies
+# Running the modipsl/util/ins_make command is needed AFTER
+# fait_AA_make.
+#
+# Method :
+# We use temporary files to perform the following steps :
+#    1- search all CPP keys in the code
+#    2- write compilation rules 
+#    3- add compilation options add the beginning of AA_make 
+#    4- search and write dependancies
+#    5- add some specific rules (links creation in the WORK)
+#
+############################################################
+#-
+echo "This script must be run while in the modipsl/modeles/NEMO directory"
 cd WORK
 pwd
-#MODEL_LIB=../../../lib/libopa.a
-#MODEL_LIB=`grep MODEL_LIB AA_make.ldef | sed 's/ //g' | sed 's/MODEL_LIB=//g' `
-liste_cle=$(egrep '^# *if[!( &]*def|^# *elif' *.[Fh] *.[Fh]90 | grep key_ | sed 's/||/\
+
+#-
+#- Search CPP keys ---
+liste_cle=$(egrep '^# *if[!( &]*def|^# *elif' *.[Fh] *.[Fh]90  2> /dev/null | grep key_ | sed 's/||/\
 /' | sed 's/\&\&/\
-/' | sed 's/^.*key_/key_/' | sed 's/ *[) ] *$//' | sort -u )
-#-
-#-
-#- 3) Ecriture du AA_make
-#-
-#- enteteFait_AA_make     
-#-
+/' | sed 's/^.*key_/key_/' | sed 's/ *[) ] *$//' | sort -u  )
+
+#-
+#- Write main compilation rules ---
 cat > tampon <<end
-#
+
 .SUFFIXES: .f90 .F90 .F
-#
+
 # Target
 all: 		diroce \$(EXEC_BIN)
 		@cp SRC_FILE_LIST.temp SRC_FILE_LIST
 		@echo OPA model is OK
-# cleaning objects, libraries and executables
+# Cleaning objects, libraries and executables
 clean:
+ifeq (\$(AGRIF),use)
+		-@(cd OPAFILES; ./efface)
+endif
 		\$(RM) model.o \$(MODDIR)/oce/*.mod \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN)
 		@echo OPA model \(.o .mod libraries and executables are removed\)
-# dependancies
+
+# Dependancies
 diroce:
 		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
 
-\$(EXEC_BIN) :	libioipsl key keyverif src_file_list \$(MODEL_LIB) \$(IOIPSL_LIB) model.o
+\$(EXEC_BIN) :	libioipsl key keyverif src_file_list libagrif \$(MODEL_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) agrif2model.o model.o
+ifeq (\$(AGRIF),use)
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o agrif2model.o \$(SXMODEL_LIB) \$(OASISMPI2_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
+else
 		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o \$(SXMODEL_LIB) \$(OASISMPI2_LIB) \$(IOIPSL_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
-
+endif
+
+# Agrif library and conv
+libagrif :
+ifeq (\$(AGRIF),use)
+	@( if [ ! -d OPAFILES ]; then mkdir OPAFILES; fi )
+	@( if [ ! -d OPAFILES/AGRIF_INC ]; then mkdir OPAFILES/AGRIF_INC ; fi )
+	@( if [ ! -d OPAFILES/AGRIF_MODELFILES ]; then mkdir OPAFILES/AGRIF_MODELFILES ; fi )
+	@(cd ../../AGRIF ; \$(M_K) -f Makefile P_P="\$(AGRIF_MPI)" )
+	@cp -rf ../../AGRIF/agrif_opa.in OPAFILES/. 
+	@cp -rf ../../AGRIF/conv OPAFILES/. 
+	@cp -rf ../../AGRIF/efface OPAFILES/. 
+endif
+
+# Agrif interface with NEMO
+agrif2model.o :
+ifeq (\$(AGRIF),use)
+	@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+	@\$(F_C) \\
+#-Q- aix		-qsuffix=f=F90 \\
+#-Q- osxxlf		-qsuffix=f=F90 \\
+	\$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sxnec		-R2 \\
+#-Q- sx6nec		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix		-qsource \\
+	   OPAFILES/\$*.F90 || { mv \$(PREF).L \$(TMP) ; false ; exit ; }
+		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null 
+endif
+
+# IOIPSL library 
 libioipsl :
 	(cd ../../IOIPSL/src ; \$(M_K) -f Makefile )
 
-# main program
+# Main program
 model.o :	model.f90
 		@\$(F_C) \$(F_O) -c model.f90
@@ -55,5 +113,5 @@
 		@echo
 
-# Rules
+# Default rules
 .DEFAULTS:
 
@@ -81,5 +139,21 @@
 
 # rules for the .F90 files
-.F90.a :           
+.F90.a :  
+ifeq (\$(AGRIF),use) 
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \\
+		-comdirin ./ -comdirout AGRIF_MODELFILES/. -convfile \$*.F90)
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC OPAFILES/\$*.F90 > OPAFILES/AGRIF_MODELFILES/\$*.F90
+		-@mv -f OPAFILES/AGRIF_MODELFILES/\$*.F90 OPAFILES/\$*.F90
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sxnec		-R2 \\
+#-Q- sx6nec		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix		-qsource \\
+		OPAFILES/\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; } 
+else
 		@\$(F_C) \$(P_P) \$(F_O) \\
 #-Q- fjvpp		-Z \$*.L \\
@@ -90,4 +164,5 @@
 #-Q- aix		-qsource \\
 		\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+endif
 #-Q- sxnec		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
 #-Q- sx6nec		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
@@ -144,9 +219,8 @@
 #-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
 		@if [ -f \$(PREF)\$*.L ] ; then mv \$*.L \$(TMP) ; fi
-#
+
 end
 #-
-#- dependances
-#-
+#- Compilation options ---
 exec 1> AA_make
 MAIN="model"
@@ -154,15 +228,15 @@
 echo '# some variables'
 echo 'TMP = ../../../tmp'
-echo '#-Q- sxnec  # Compiler options for the ORCA model   -   std'
+echo '#-Q- sxnec  # Compiler options for NEMO (IDRIS SX5-NEC) '
 echo '#-Q- sxnec  F_O = -dw -Wf\"-A idbl4\" -sx5 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- sxnec  L_X = $(L_O) $(L_C) -ftrace'
-echo '#-Q- sx6nec  # Compiler options for the ORCA model   -   std'
+echo '#-Q- sx6nec  # Compiler options NEMO (CEA SX6-NEC) '
 echo '#-Q- sx6nec  F_O = -size_t64 -dw -Wf\"-A dbl4\" -sx6 -C vopt -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 -L transform' -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- sx6nec  F_O = -size_t64 -dw -Wf\"-A dbl4\" -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- sx6nec  L_X = $(L_O) $(L_C) -ftrace'
-echo '#-Q- sxdkrz  # Compiler options for the ORCA model for the DKRZ SX6-NEC '
+echo '#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) '
 echo '#-Q- sxdkrz  F_O = -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- sxdkrz  L_X = $(L_O) $(L_C) -ftrace'
-echo '#-Q- eshpux  # Compiler options for the ORCA model for the ES'
+echo '#-Q- eshpux  # Compiler options for NEMO (Earth Simulator)'
 echo '#-Q- eshpux  # for super perfs!'
 echo '#-Q- eshpux  # F_O = $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce'
@@ -170,18 +244,21 @@
 echo '#-Q- eshpux  F_O = $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- eshpux  L_X = $(L_O)'
-echo '#-Q- linux  # Compiler options for the ORCA model (pgf version)'
+echo '#-Q- linux  # Compiler options for NEMO (pgf version)'
 echo '#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce'
 echo '#-Q- linux  L_X = -r8 -O3'
-echo '#-Q- lxiv8  # Compiler options for the ORCA model (ifort version)'
+echo '#-Q- lxiv7  # Compiler options for NEMO (ifc version)'
+echo '#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce'
+echo '#-Q- lxiv7  L_X = -r8 -O3'
+echo '#-Q- lxiv8  # Compiler options for NEMO (ifort version)'
 echo '#-Q- lxiv8  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce'
 echo '#-Q- lxiv8  L_X = -r8 -O3'
-echo '#-Q- g95  # Compiler options for the ORCA model (g95 version)'
+echo '#-Q- g95  # Compiler options for NEMO (g95 version)'
 echo '#-Q- g95  F_O = -O3 -fno-second-underscore -r8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce'
 echo '#-Q- g95  L_X = -r8 -O3'
-echo '#-Q- aix    # Compiler options for the ORCA model (aix version)'
+echo '#-Q- aix    # Compiler options for NEMO (aix version)'
 echo '#-Q- aix    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce' 
 echo '#-Q- aix   L_O = $(F_P) -q64 -O3'
 echo '#-Q- aix   L_X = $(L_O) $(L_C) '
-echo '#-Q- osxxlf    # Compiler options for the ORCA model (osxxlf version)'
+echo '#-Q- osxxlf    # Compiler options for NEMO (osxxlf version)'
 echo '#-Q- osxxlf    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce' 
 echo '#-Q- osxxlf    L_X = -qrealsize=8 -O3'
@@ -192,4 +269,22 @@
 echo '#-Q- sxdkrz	PREF=i.'
 echo '#-Q- eshpux	PREF=i.'
+echo ''
+echo '# add suffix to P_P'
+echo 'P_P := $(P_P:%=$(prefix)%)'
+echo ''
+echo '# Some tests to define variables related to Agrif compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_agrif,$(P_P)))'
+echo 'AGRIF=use'
+echo 'else'
+echo 'AGRIF=notuse'
+echo 'AGRIF_LIB='
+echo 'endif'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'AGRIF_MPI=-DAGRIF_MPI'
+echo 'else'
+echo 'AGRIF_MPI='
+echo 'endif'
+
 echo ''
 # Write the cpp key list with one key by line
@@ -205,54 +300,70 @@
 echo 'LIB_OBJ = \c'
 #
-# allons chercher tous les .f du repertoire courant
-# construction de la liste des objets LIB_OBJ
-
-for i in `ls *.f`
+# find all .f in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.f 2> /dev/null`
 do
   bn=`basename $i .f`
   if [ "${bn}" != "${MAIN}" ] 
   then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
     echo "\\"
     echo "		\$(MODEL_LIB)($bn.o)\c"
   fi
+  fi
 done
 
-# allons chercher tous les .f90 du repertoire courant
-# construction de la liste des objets LIB_OBJ
+# find all .f90 in the current directory
+# build object files list  LIB_OBJ
 # one dependancy by line
-for i in `ls *.f90`
+
+for i in `ls *.f90  `
 do
   bn=`basename $i .f90`
   if [ "${bn}" != "${MAIN}" ] 
   then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
     echo "\\"
     echo "		\$(MODEL_LIB)($bn.o)\c"
   fi
+  fi
 done
 
-# allons chercher tous les .F90 du repertoire courant
-# construction de la liste des objets LIB_OBJ
-
-for i in `ls *.F90`
+# find all .F90 in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.F90  `
 do
   bn=`basename $i .F90`
   if [ "${bn}" != "${MAIN}" ] 
   then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
     echo "\\"
     echo "		\$(MODEL_LIB)($bn.o)\c"
   fi
+  fi
 done
 
-# allons chercher tous les .F du repertoire courant
-# construction de la liste des objets LIB_OBJ
-
-for i in `ls *.F`
+# find all .F in the current directory
+# build object files list  LIB_OBJ
+# one dependancy by line
+
+for i in `ls *.F 2> /dev/null `
 do
   bn=`basename $i .F`
   if [ "${bn}" != "${MAIN}" ] 
   then 
+  if [ "${bn}" != "agrif2model" ] 
+  then 
     echo "\\"
     echo "		\$(MODEL_LIB)($bn.o)\c"
   fi
+  fi
  done
 
@@ -261,8 +372,11 @@
 cat tampon
 rm tampon
-
-#
-for fic in `ls *.f90 *.F90  *.F `
+#-
+#- Write all dependancies ---
+
+for fic in `ls *.f90 *.F90  *.F 2> /dev/null `
 do
+    if [ "${fic}" != "agrif2model.F90" ]
+    then
     if [ "${fic}" != "${MAIN}.[Ff]" ]
     then
@@ -277,5 +391,5 @@
 	luse2=""
 	luse3=""
-# on cherche les includes type modele de glace LLN
+#- search include files (old ice model form, should it be suppressed ?)
 	for inc in `sed -n 's/^[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
 	do
@@ -283,5 +397,5 @@
 	done
 
-# on cherche les includes (et les includes des includes et ainsi de suite pour 3 niveaux max)
+#- search include files on 3 levels
 	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
 	do
@@ -291,5 +405,5 @@
 		do
 		    dep="$dep\n$inc2"
-		    # on cherche les include  dans le fichier deja include (3eme niveau! balaise!)
+		    #- search include  in include (third level !!!)
 		    for inc3 in `sed -n 's/^#[  	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc2 | sort -u`
 		    do
@@ -299,5 +413,5 @@
 	done
 
-# on cherche les USE dans les include
+#- search USE in include files
 	for inc in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $fic | sort -u`
 	do
@@ -306,11 +420,17 @@
 	        if [ $fuse0 != "ioipsl" ] 
                 then
+                if [ $fuse0 != "Agrif_Util" ] 
+                then
+                if [ $fuse0 != "Agrif_Types" ] 
+                then
 		    lfuse0=$fuse0.f90
 		    [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
 		    luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
                 fi
+                fi
+                fi
 		done
 
-# on cherche aussi les USE dans les include des include on les ajoute a luse0
+#- search USE in  files included in included files and add to luse0
 
 		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
@@ -320,16 +440,26 @@
 	            if [ $fuse0 != "ioipsl" ] 
                     then
+                    if [ $fuse0 != "Agrif_Util" ] 
+                    then
+                    if [ $fuse0 != "Agrif_Types" ] 
+                    then
 		        lfuse0=$fuse0.f90
 		        [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
 		        luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
                     fi
+                    fi
+                    fi
 		    done
   	        done
 	done
 
-# on cherche les USE (et les USE des USE et ainsi de suite pour 3 niveaux max)
+#- search USE (and USE of USE and so on three levels)
 	for fuse1 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $fic | sort -u`
 	do
 	if [ $fuse1 != "ioipsl" ] 
+        then
+        if [ $fuse1 != "Agrif_Util" ] 
+        then
+        if [ $fuse1 != "Agrif_Types" ] 
         then
 	    lfuse1=$fuse1.f90
@@ -339,4 +469,8 @@
 		do
 	        if [ $fuse2 != "ioipsl" ] 
+                then
+                if [ $fuse2 != "Agrif_Util" ] 
+                then
+                if [ $fuse2 != "Agrif_Types" ] 
                 then
 		    lfuse2=$fuse2.f90
@@ -348,13 +482,23 @@
 		    if [ $fuse3 != "ioipsl" ] 
                     then
+                    if [ $fuse3 != "Agrif_Util" ] 
+                    then
+                    if [ $fuse3 != "Agrif_Types" ] 
+                    then
 			luse3="$luse3\n$lfuse3\n\$(MODEL_LIB)($fuse3.o)"
+                    fi		    
+                    fi		    
                     fi		    
                     done
                 fi
+                fi
+                fi
 		done
         fi
+        fi
+        fi
 	done
-#- la variable dep contient l'ensemble des dependances mais peut-etre en double ou plus
-#-
+#-
+#-  dep contains all dependancies 
 	for depele in `echo $luse3 | sort -u` `echo $luse2 | sort -u` `echo $luse1 | sort -u` `echo $luse0 | sort -u` `echo $dep | sort -u`
 	do
@@ -366,8 +510,13 @@
 
 #-
-#- on ajoute la dependance avec la librairie ioipsl si besoin cad si le source contient use ioipsl
-        grep -i 'use *ioipsl' ${fic} >/dev/null && ( echo "\\" ; echo "	../../../lib/libioipsl.a \c")
-
-#- on ajoute la dependance avec KEY_CPP si il y a des include cpp
+#- add dependancies with IOIPSL library (if source files contains IOIPSL)
+        grep -i 'use *ioipsl' ${fic} >/dev/null && ( echo "\\" ; echo "	\$(IOIPSL_LIB) \c")
+
+#-
+#- add dependancies with IOIPSL library (if source files contains Agrif_*)
+        grep -i 'use Agrif_*' ${fic} >/dev/null && ( echo "\\" ; echo "	\($AGRIF_LIB) \c")
+
+#-
+#- on ajoute la dependance avecadd dependancies with KEY_CPP (if source file inclides cp  keys)
 	if [ ${j} != "0" ] 
         then 
@@ -375,5 +524,6 @@
 	  echo "	KEY_CPP \c" 
 	fi
-#- on finit la dependance avec le fichier lui-meme et on ecrit les regles de creation
+#-
+#- end with the file itself
 	if [ ${i} != "0" ] 
         then 
@@ -382,22 +532,20 @@
          fi
     fi
+    fi
 echo $fic done >/dev/tty
 done
+#-
+#- Write some special rules ---
 echo '# key changing control'
 echo "key: "
-echo "	@echo CHANGEMENT de CLES CPP oui/non ?"
-echo "	-@if [ \"\`cat KEY_CPP\`\" != \"\$(P_P)\" ] ; then \\"
-echo "		echo CPP options changed ; echo \"\$(P_P)\" > KEY_CPP ; fi "
-#-
-#
-# regle pour verifier les cles
-# EK novembre 2000
-# adaptation : ED + MAF decembre 2000
-#
-echo
+echo "	@echo CHANGE of CPP KEYS yes/no ?"
+echo "	-@if [ \"\`cat KEY_CPP\`\" != \"\$(P_P:\$(prefix)%=%)\" ] ; then \\"
+echo "		echo CPP options changed ; echo \"\$(P_P:\$(prefix)%=%)\" > KEY_CPP ; fi "
+#-
+echo '# check key values'
 echo "keyverif:"
-echo '	@echo VERIFICATION DES CLES'
-echo '	@echo CLES UTILISEES  : '
-echo '	@for v in ` echo $(P_P) | sed  -e s/-Wp,-D//g` ; \'
+echo '	@echo CHECKING KEY'
+echo '	@echo KEY USED : '
+echo '	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \'
 echo '	do \'
 echo '	echo $$v ;\'
@@ -413,9 +561,8 @@
 echo '        fi \'
 echo '	done'
-# Checking if the number of routines have been changed
 echo '# Checking the number of routines'
 echo "src_file_list: "
 echo '	@echo CHECKING THE NUMBER AND NAMES OF SOURCE FILES '
-echo '	@\$(RM) `ls | fgrep -v -f .patron` '
+echo '	@$(RM) `ls | fgrep -v -f .patron` '
 echo '	@check=`grep OPA_SRC .config`              ; \'
 echo '	if [ -n "$$check" ] ; then                   \'
@@ -439,4 +586,12 @@
 echo '	echo "   use LIM_SRC files"                ; \'
 echo '      ln -sf ../LIM_SRC/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep NST_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use NST_SRC files"                ; \'
+echo '      \$(RM) agrif_opa_interp.F90           ; \'
+echo '      \$(RM) agrif_opa_sponge.F90           ; \'
+echo '      \$(RM) agrif_opa_update.F90           ; \'
+echo '      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \'
 echo '  fi '
 echo '	@check=`grep C1D_SRC .config`              ; \'
@@ -472,3 +627,4 @@
 echo '	echo "========================================== " ; \'
 echo '	../../util/ins_make ; echo " " ;  false ; exit ; }'
-
+exec > /dev/null
+
Index: /trunk/UTIL/fait_config
===================================================================
--- /trunk/UTIL/fait_config	(revision 393)
+++ /trunk/UTIL/fait_config	(revision 394)
@@ -34,6 +34,6 @@
 
 LIST="ORCA2_LIM \nGYRE"
-set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC C1D_SRC
-set -A DIR_GYRE OPA_SRC LIM_SRC C1D_SRC
+set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC C1D_SRC NST_SRC
+set -A DIR_GYRE OPA_SRC LIM_SRC C1D_SRC 
 
 ###################################
@@ -67,5 +67,5 @@
 #- Clean links and librairies
 [ -f Makefile ] && gmake clean 
-[ -n "`\ls`" ] && \rm * 
+[ -n "`\ls`" ] && \rm -rf * 
 
 #- Find the number of directories ---
@@ -110,4 +110,10 @@
 	  ln -sf ../TOP_SRC/TRP/*.[Ffh]90 .
       
+      elif [ "${TAB[i]}" = "NST_SRC" ]; then
+	  [ -f  agrif_opa_interp.F90 ] && \rm agrif_opa_interp.F90                    
+	  [ -f  agrif_opa_sponge.F90 ] && \rm agrif_opa_sponge.F90                    
+	  [ -f  agrif_opa_update.F90 ] && \rm agrif_opa_update.F90                    
+	  ln -sf ../NST_SRC/*.[Ffh]90 .
+      
       elif [ "${TAB[i]}" = "OFF_SRC" ]; then  
 	  ln -sf ../OFF_SRC/*.[Ffh]90 .
@@ -120,4 +126,5 @@
     ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; 
     ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ;
+    ln -sf ../../../*/${m_n}/scripts/BB_make_Agrif AA_make_Agrif ;
 
 else
@@ -150,9 +157,10 @@
 icdyna.f
 thersf.f
+OPAFILES
 EOF
 ls -1 | fgrep -v -f .patron  >SRC_FILE_LIST ; cp SRC_FILE_LIST SRC_FILE_LIST.temp ;
 
 #- Writing KEY_CPP file ---
-sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP;    
+sed -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP;    
 
 #- Save new configuration an d directories names ---
