Index: /branches/DEV_r1879_FCM/NEMOGCM/UTIL/chk_iomput.sh
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/UTIL/chk_iomput.sh	(revision 1909)
+++ /branches/DEV_r1879_FCM/NEMOGCM/UTIL/chk_iomput.sh	(revision 1909)
@@ -0,0 +1,95 @@
+#!/bin/bash
+#------------------------------------------------
+#$Id$
+#------------------------------------------------
+#
+set -u
+#
+inxml=0
+insrc=0
+xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
+srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
+while [ $# -gt 0 ]   # Until you run out of parameters . . . 
+do    
+    case "$1" in 
+        --inxml) inxml=1 ;;
+        --insrc) insrc=1 ;;
+	*) xmlfile=${1:-"../CONFIG/ORCA2_LIM/EXP00/iodef.xml"}
+	   srcdir=${2:-"../NEMO/OPA_SRC ../NEMO/LIM_SRC_2"}
+	   shift
+    esac
+    shift       # Check next set of parameters. 
+done 
+#
+#------------------------------------------------
+#
+[ $inxml -eq 1 ] && grep "< *field * id *=" $xmlfile
+[ $insrc -eq 1 ] && find $srcdir -name "*.[Ffh]90" -exec grep -iH "^[^\!]*call  *iom_put *(" {} \;
+[ $(( $insrc + $inxml )) -ge 1 ] && exit
+#
+#------------------------------------------------
+#
+# list of file containing "CALL iom_put" in $srcdir
+#
+srclist=$( find $srcdir -name "*.[Ffh]90" -exec grep -il "^[^\!]*call  *iom_put *(" {} \; )
+#
+# list of variables used in "CALL iom_put"
+#
+varlistsrc=$( find $srcdir -name "*.[Ffh]90" -exec grep -i  "^[^\!]*call  *iom_put *(" {} \; | sed -e "s/.*iom_put *( *[\"\']\([^\"\']*\)[\"\'] *,.*/\1/" | sort -d )
+#
+# list of variables defined in the xml file
+#
+varlistxml=$( grep "< *field * id *=" $xmlfile  | sed -e "s/^.*< *field * id *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+# list of variables to be outputed in the xml file
+#
+varlistout=$( grep "< *field * ref *=" $xmlfile  | sed -e "s/^.*< *field * ref *= *[\"\']\([^\"\']*\)[\"\'].*/\1/" | sort -d )
+#
+echo "--------------------------------------------------"
+echo  check if all iom_put found in $srcdir
+echo  have a corresponding variable definition in $xmlfile
+echo "--------------------------------------------------"
+for var in $varlistsrc
+do
+    tst=$( echo " "$varlistxml" " | grep -c " $var " )
+    if [ $tst -ne 1 ] 
+    then
+	echo "$tst problem with $var, defined in"
+	for f in $srclist
+	do
+	    grep -iH "^[^\!]*call  *iom_put *( *[\"\']${var}[\"\'] *," $f
+	done
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  check if all variables defined in $xmlfile
+echo  have a corresponding \"call iom_put\" in sources found in $srcdir
+echo "--------------------------------------------------"
+#
+for var in $varlistxml
+do
+    found=$( echo " "$varlistsrc" " | grep -c " $var " )
+    if [ $found -eq 0 ] 
+    then
+	echo \"call iom_put\" not found for variable $var
+	grep "< *field * id *= *[\"\']${var}[\"\']" $xmlfile
+	echo
+    fi
+done
+#
+echo "--------------------------------------------------"
+echo  ${xmlfile}: check if all variables to be outputed in files are really defined...
+echo "--------------------------------------------------"
+#
+# list of variables defined in the xml file
+for var in $varlistout
+do
+    found=$( echo " "$varlistxml" " | grep -c " $var " )
+    [ $found -eq 0 ] && echo variable to be outputed but not defined: $var 
+done
+
+
+
+exit
Index: /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_AA_make
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_AA_make	(revision 1909)
+++ /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_AA_make	(revision 1909)
@@ -0,0 +1,612 @@
+#!/bin/ksh
+#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)
+#
+# Modification : - add F_F for .F file compiler option on aix
+#                - add KEY_CPP dependancy for source containing 
+#                              only #if defined CPP statement
+#
+############################################################
+#-
+echo "This script must be run while in the modipsl/modeles/NEMO directory"
+cd WORK || exit
+pwd
+
+# Test version of echo
+stringtest=`echo "\c"`
+if [ "$stringtest" ]; then
+   echo 'aliasing echo with /bin/echo -e ...'
+   alias echo='echo -e'
+fi
+
+#-
+#- 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  )
+
+#-
+#- 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
+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
+diroce:
+		@if [ ! -d ../../../lib/oce ] ; then mkdir ../../../lib/oce ; fi
+
+\$(EXEC_BIN) :	libioipsl libioserver firstagrif mpiagrif 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) \$(USER_LIB) \$(IOIPSL_LIB) \$(AGRIF_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
+else
+		\$(F_L) \$(L_X) -o \$(EXEC_BIN) model.o \$(SXMODEL_LIB) \$(USER_LIB) \$(IOIPSL_LIB) \$(NCDF_LIB) \$(LIBMPI) \$(LIBMP)
+endif
+
+# ioserver library
+libioserver :
+ifeq (\$(IOSERVER),use)
+ifeq (\$(FCM),use)
+	(cd ../../XMLF90; ./configure -arch \$(FCM_ARCH); fcm build; mkdir -p ../../lib/libxmlio_server  ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLF90/lib/*.a .; ln -sf ../../modeles/XMLF90/inc/*.mod .)
+	(cd ../../XMLIO_SERVER; ./configure -arch \$(FCM_ARCH); fcm build ; cd ../../lib/libxmlio_server ; ln -sf ../../modeles/XMLIO_SERVER/lib/*.a . ; ln -sf ../../modeles/XMLIO_SERVER/inc/* . ; cd ../../bin ; ln -sf ../modeles/XMLIO_SERVER/bin/server.exe ioserver)
+else
+	(cd ../../XMLF90/external ; \$(M_K) -f Makefile )
+	(cd ../../XMLIO_SERVER/external ; \$(M_K) -f Makefile P_P="\$(IOSERVER_MPI)" )
+endif
+endif
+
+# Agrif library and conv
+libagrif :  \$(call keycompat,key_iomput,key_agrif)
+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- aix6		-qsuffix=f=F90 \\
+#-Q- babel		-qsuffix=f=F90 \\
+#-Q- osxxlf		-qsuffix=f=F90 \\
+	\$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix6		-qsource \\
+#-Q- aix		-qsource \\
+#-Q- babel		-qsource \\
+	   OPAFILES/\$*.F90 || { mv \$(PREF).L \$(TMP) ; false ; exit ; }
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- eshpux			@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+endif
+
+# IOIPSL library 
+libioipsl :
+	(cd ../../IOIPSL/src ; \$(M_K) -f Makefile )
+
+# Main program
+model.o :	model.f90
+		@\$(F_C) \$(F_O) -c model.f90
+
+# if the make script is stopped, one doesn't destroy library
+.PRECIOUS : \$(MODEL_LIB)
+#-Q- sxdkrz .PRECIOUS : \$(SXMODEL_LIB)
+#-Q- eshpux .PRECIOUS : \$(SXMODEL_LIB)
+
+# library dependancies
+\$(MODEL_LIB):	\$(LIB_OBJ)
+		@echo
+		@echo The library is up-to-date
+		@echo
+
+# Default rules
+.DEFAULTS:
+
+# rules for the .f90 files
+.f90.a :           
+		@\$(F_C) \$(P_P) \$(F_O) \\
+#-Q- fjvpp		-Z \$*.L \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.f90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- eshpux		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+		@\$(A_C) \$(MODEL_LIB) \$*.o  > /dev/null
+		@\$(RM) \$*.[of]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce ; fi
+#-Q- aix		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+# rules for the .F90 files
+.F90.a :  
+ifeq (\$(AGRIF),use) 
+		@\$(P_C) \$(P_O) -IOPAFILES/AGRIF_INC \$*.F90 > OPAFILES/\$*.F90 
+		@(cd OPAFILES ; ./conv agrif_opa.in -rm \\
+#-Q- linux		-SubloopScalar \\
+#-Q- g95			-SubloopScalar \\
+#-Q- f95			-SubloopScalar \\
+#-Q- osf1			-SubloopScalar \\
+		-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- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-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 \\
+#-Q- sx8mercure		-R2 \\
+#-Q- sx9mercure		-R2 \\
+#-Q- sx8brodie		-R2 \\
+#-Q- sxdkrz		-R2 \\
+#-Q- eshpux		-R2 \\
+#-Q- aix		-qsource \\
+#-Q- aix6		-qsource \\
+#-Q- babel		-qsource \\
+		\$*.F90 || { if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi ; false ; exit ; }
+endif
+#-Q- sxdkrz		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+#-Q- eshpux		@\$(A_X) \$(SXMODEL_LIB) \$*.o  > /dev/null
+		@\$(A_C) \$(MODEL_LIB) \$*.o  > /dev/null
+		@\$(RM) \$*.[of]
+		@if [ -f \$*.mod ] ; then mv \$*.mod \$(MODDIR)/oce ; fi
+#-Q- aix		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- aix6		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- babel		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- linux		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+#-Q- osxxlf		@mv \$(PREF)\$*.lst \$(PREF)\$*.L
+		@if [ -f \$(PREF)\$*.L ] ; then mv \$(PREF)\$*.L \$(TMP) ; fi
+
+end
+#-
+#- Compilation options ---
+exec 1> AA_make
+MAIN="model"
+echo '# $Header$'
+echo '# some variables'
+echo 'TMP = ../../../tmp'
+echo ''
+echo '#WARNING : NEMO does NOT support fortran 95 signed zero behaviour when using intrinsec SIGN function'
+echo '#          This doesnt happen whith Fortran 90 compilers but'
+echo '#          Check your compilers option in consequence when using real F95 compilers'
+echo ''
+echo '#-Q- platine # Compiler options NEMO (CCRT Itanium Bull) '
+echo '#-Q- platine F_O = -O3 -i4 -r8 -module $(MODDIR)/oce -I$(MODDIR) -I$(MODDIR)/oce -I$(NCDF_INC) $(USER_INC) '
+echo '#-Q- platine L_X = $(L_O) '
+echo '#-Q- sx8mercure  # Compiler options NEMO (CCRT SX8-NEC) '
+echo '#-Q- sx8mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -sx8 -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 shape=10000000 -L transform' -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) '
+echo '#-Q- sx8mercure  L_X = $(L_O)'
+echo '#-Q- sx9mercure  # Compiler options NEMO (CCRT SX9-NEC) '
+echo '#-Q- sx9mercure  F_O = -f2003 nocbind -size_t64 -dw -Wf\"-A dbl4\" -C vopt -P stack -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-P nh" -Wf',-pvctl noassume loopcnt=10000 shape=10000000 -L transform' -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC) '
+echo '#-Q- sx9mercure  L_X = $(L_O)'
+echo '#-Q- sx8brodie  # Compiler options NEMO (IDRIS SX8-NEC) '
+echo '#-Q- sx8brodie  F_O =  -f2003 nocbind -dw -Wf\"-A idbl4\" -sx8 -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sx8brodie  L_X = $(L_O)'
+echo '#-Q- sxdkrz  # Compiler options for NEMO (DKRZ SX6-NEC) '
+echo '#-Q- sxdkrz  F_O =  -f2003 nocbind -ew -sx6 -ftrace -C vopt -Wf"-init stack=nan" -Wl"-f nan" -Wf"-P nh -O overlap" -Wf"-pvctl noassume loopcnt=10000" -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- sxdkrz  L_X = $(L_O) -ftrace'
+echo '#-Q- eshpux  # Compiler options for NEMO (Earth Simulator)'
+echo '#-Q- eshpux  # for super perfs!'
+echo '#-Q- eshpux  # F_O = -f2003 nocbind $(FTRACE) -pi nest=5 line=10000 expin=Fmpplib.F -Wf,-A idbl4 -C hopt -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- eshpux  # regular options!'
+echo '#-Q- eshpux  F_O = -f2003 nocbind $(FTRACE) -Wf,-A idbl4 -C vopt -P stack -Wf"-P nh -O overlap" -Wf,-pvctl noassume loopcnt=10000 -L transform -Wf,-pvctl nomsg -Wf"-O nomsg" -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- eshpux  L_X = $(L_O)'
+echo '#-Q- linux  # Compiler options for NEMO (pgf version)'
+echo '#-Q- linux  F_O = -Mlist -O3 -byteswapio -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- linux  L_X = -r8 -O3'
+echo '#-Q- lxiv7  # Compiler options for NEMO (ifc version)'
+echo '#-Q- lxiv7  F_O = -O3 -r8  -I $(MODDIR) -I$(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+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 -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- lxiv8  L_X = -r8 -O3'
+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 -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- g95  L_X = -r8 -O3'
+echo '#-Q- gfortran  # Compiler options for NEMO (gfortran version)'
+echo '#-Q- gfortran  F_O = -fno-second-underscore -fdefault-real-8 -funroll-all-loops -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- gfortran  L_X = -fdefault-real-8'
+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 -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- aix   L_O = $(F_P) -q64 -O3'
+echo '#-Q- aix   L_X = $(L_O)'
+echo '#-Q- aix6    # Compiler options for NEMO (aix6 version)'
+echo '#-Q- aix6    F_O = -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qextname -qsource -q64 -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- aix6   L_O = $(F_P) -q64 -O3'
+echo '#-Q- aix6   L_X = $(L_O)'
+echo '#-Q- babel  # Compiler options for NEMO (blue gene version)'
+echo '#-Q- babel  F_O =  -O3 -qsave -qrealsize=8 -qsuffix=f=f90 -qsuffix=cpp=F90 -qsource -qextname=flush -qlargepage -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)'
+echo '#-Q- babel  L_X = $(L_O)'
+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 -qextname -qstrict -qmaxmem=-1 -I $(MODDIR) -I $(MODDIR)/oce -I $(NCDF_INC) $(USER_INC)' 
+echo '#-Q- osxxlf    L_X = -qrealsize=8 -O3'
+
+echo 'PREF='
+echo '#-Q- sx8mercure	PREF=i.'
+echo '#-Q- sx9mercure	PREF=i.'
+echo '#-Q- sx8brodie	PREF=i.'
+echo '#-Q- sxdkrz	PREF=i.'
+echo '#-Q- eshpux	PREF=i.'
+echo ''
+echo '# add suffix to P_P'
+echo 'override 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 ''
+echo '# Some tests to define variables related to xmlioserver compilation'
+echo '# Please do not change '
+echo 'ifneq (,$(findstring key_iomput,$(P_P)))'
+echo 'IOSERVER=use'
+echo 'override USER_LIB += -L../../../lib/libxmlio_server -lioserver -lxmlio -lxmlf90'
+echo 'override USER_INC += -I../../../lib/libxmlio_server'
+echo 'ifneq (,$(findstring key_mpp_mpi,$(P_P)))'
+echo 'IOSERVER_MPI='
+echo 'else'
+echo 'IOSERVER_MPI=-DNO_MPI'
+echo 'endif'
+echo 'else'
+echo 'IOSERVER=notuse'
+echo 'endif'
+echo ''
+
+echo '# A variables related to xmlioserver compilationi (fcm or AA_make)'
+echo '# Please do not change '
+echo 'override FCM ?= notuse'
+echo ''
+
+echo '#check key compatibility'
+echo 'keycompat=$(if $(and $(findstring $1,$(P_P)),$(findstring $2,$(P_P))),$(error $1 and $2 NOT compatible))'
+
+echo ''
+# Write the cpp key list with one key by line
+echo 'KEY_LIST = \c'
+for i in ${liste_cle}
+do
+ echo "\\"
+ echo "     $i \c"
+done
+
+echo ''
+echo '# .o file list in the library'
+echo 'LIB_OBJ = \c'
+#
+# 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
+
+# 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
+
+echo ""
+
+cat tampon
+rm tampon
+#-
+#- Write all dependancies ---
+
+for fic in `ls *.f90 *.F90  *.F 2> /dev/null `
+do
+    if [ "${fic}" != "agrif2model.F90" ]
+    then
+    if [ "${fic}" != "${MAIN}.[Ff]" ]
+    then
+	i=0
+	j=0
+	dep=""
+	inc=""
+	inc2=""
+	inc3=""
+	luse0=""
+	luse1=""
+	luse2=""
+	luse3=""
+        key=""
+#- 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
+	    dep="$dep\n$inc"
+	done
+
+#- take into account CPP dependancies  keys only (par_trc_trp example)
+	for key in `sed -n 's/^#[ 	eElL]*[iF][fF][ 	]*[dD][eE][fF][iI][nN][eE][dD][ 	]*//p' $fic | sort -u`
+	do
+	    j=1
+	done
+
+#- 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
+	    j=1
+	    dep="$dep\n$inc"
+		for inc2 in `sed -n 's/^#[ 	]*[iI][nN][cC][lL][uU][dD][eE][ 	]*\(['\''"]\)\([^'\''"]*\)\1.*/\2/p' $inc | sort -u`
+		do
+		    dep="$dep\n$inc2"
+		    #- 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
+			dep="$dep\n$inc3"
+		    done
+		done
+	done
+
+#- 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
+		for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc | sort -u`
+		do
+                    [ -f $fuse0.[hfF]90 ] || continue
+		    lfuse0=$fuse0.f90
+		    [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		    luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
+		done
+
+#- 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`
+		do
+		    for fuse0 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $inc2 | sort -u`
+		    do
+                        [ -f $fuse0.[hfF]90 ] || continue
+		        lfuse0=$fuse0.f90
+		        [ -f $fuse0.F90 ] && lfuse0=$fuse0.F90
+		        luse0="$luse0\n$lfuse0\n\$(MODEL_LIB)($fuse0.o)"
+		    done
+  	        done
+	done
+
+#- 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
+            [ -f $fuse1.[hfF]90 ] || continue
+	    lfuse1=$fuse1.f90
+	    [ -f $fuse1.F90 ] && lfuse1=$fuse1.F90
+	    luse1="$luse1\n$lfuse1\n\$(MODEL_LIB)($fuse1.o)"
+		for fuse2 in `sed -n 's/^[ 	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse1 | sort -u`
+		do
+                    [ -f $fuse2.[hfF]90 ] || continue
+		    lfuse2=$fuse2.f90
+		    [ -f $fuse2.F90 ] && lfuse2=$fuse2.F90
+		    luse2="$luse2\n$lfuse2\n\$(MODEL_LIB)($fuse2.o)"
+		    # on cherche les USE  dans le fichier deja USE (3eme niveau! balaise!)
+		    for fuse3 in `sed -n 's/^#[  	]*[uU][sS][eE] [ 	]*\([^!,;]*\).*/\1/p' $lfuse2 | sort -u`
+		    do
+                        [ -f $fuse3.[hfF]90 ] || continue
+			luse3="$luse3\n$lfuse3\n\$(MODEL_LIB)($fuse3.o)"
+                    done
+		done
+	done
+#-
+#-  dep contains all dependancies 
+	echo "\$(MODEL_LIB)(`echo $fic|awk -F. '{print $1}'`.o) :	\c"
+	for depele in `echo $luse3 | sort -u` `echo $luse2 | sort -u` `echo $luse1 | sort -u` `echo $luse0 | sort -u` `echo $dep | sort -u`
+	do
+	    echo "\\"
+ 	    echo "	$depele \c"
+ 	    let i=i+1 # pour signaler le premier
+	done
+
+#-
+#- 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")
+
+#-
+#- add dependancies with KEY_CPP (if source file includes cpp  keys)
+	if [ ${j} != "0" ] 
+        then 
+	  echo "\\"
+	  echo "	KEY_CPP \c" 
+	fi
+#-
+#- end with the file itself
+	     echo "\\"
+       	     echo "	$fic"
+    fi
+    fi
+echo $fic done >/dev/tty
+done
+#-
+#- Write some special rules ---
+echo '# agrif previous use'
+echo "firstagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo '	@if [ -z "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "else"
+echo '	@if [ -n "`cat KEY_CPP | grep key_agrif`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "endif"
+#-
+echo '#- RB : this rule is a pretty miserable trick to be able to re-compile NEMP-AGRIF-mono after NEMO-AGRIF-mpp'
+echo '#- I guess the good correction should be in AGRIF/LIB/toamr.c for the conv, to remove useless allocation declarations in AGRIF_INC'
+echo '# recompile all in this case' 
+echo "mpiagrif:"
+echo "ifeq (\$(AGRIF),use)"
+echo "ifeq (,\$(AGRIF_MPI))"
+echo '	@if [ -n "`cat KEY_CPP | grep key_mpp_mpi`" ]; then $(RM) -r OPAFILES model.o $(MODDIR)/oce/*.mod $(MODEL_LIB) $(SXMODEL_LIB); fi'
+echo "endif"
+echo "endif"
+#-
+echo '# key changing control'
+echo "key: "
+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 CHECKING KEY'
+echo '	@echo KEY USED : '
+echo '	@for v in ` echo $(P_P:$(prefix)%=%) ` ; \'
+echo '	do \'
+echo '	echo $$v ;\'
+echo '        w=`echo $$v | cut -c1-3` ; \'
+echo '        if [ $$w = `echo "key"` ] ; then \'
+echo '        r=n ; \'
+echo '        echo " $(KEY_LIST) " | (grep $$v >/dev/null 2>&1) || r=o ; \'
+echo '           if [ $$r != "n" ] ; then \'
+echo '              echo "UNKNOWN KEY" ;\'
+echo '              false ;  \'
+echo '              exit ;  \'
+echo '           fi \'
+echo '        fi \'
+echo '	done'
+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 '	@check=`grep OPA_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OPA_SRC files"                ; \'
+echo '	    ln -sf ../OPA_SRC/*.[Ffh]90          . ; \'
+echo '	    ln -sf ../OPA_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_3 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_3 files"                ; \'
+echo '      ln -sf ../LIM_SRC_3/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep LIM_SRC_2 .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use LIM_SRC_2 files"                ; \'
+echo '      ln -sf ../LIM_SRC_2/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep C1D_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use C1D_SRC files"                ; \'
+echo '      ln -sf ../C1D_SRC/*.[Ffh]90          . ; \'
+echo '  fi '
+echo '	@check=`grep TOP_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then  \'
+echo '	echo "   use TOP_SRC files"                ; \'
+echo '      ln -sf ../TOP_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../TOP_SRC/*/*.[Ffh]90      . ; \'
+echo '  fi '
+echo '	@check=`grep OFF_SRC .config`              ; \'
+echo '	if [ -n "$$check" ] ; then                   \'
+echo '	echo "   use OFF_SRC files"                ; \'
+echo '      ln -sf ../OFF_SRC/*.[Ffh]90          . ; \'
+echo '      ln -sf ../OFF_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 '      \$(RM) agrif_top_interp.F90           ; \'
+echo '      \$(RM) agrif_top_sponge.F90           ; \'
+echo '      \$(RM) agrif_top_update.F90           ; \'
+echo '      ln -sf ../NST_SRC/*.[Ffh]90      .     ; \'
+echo '  fi '
+echo '	@\$(RM) tmplist'
+echo '	@ls -1 | fgrep -v -f .patron  >tmplist'
+echo '	@cmp tmplist SRC_FILE_LIST.temp || { echo some routines have been added or suppressed ; \'
+echo '	sdiff -s tmplist SRC_FILE_LIST.temp ; cp tmplist SRC_FILE_LIST.temp ; \'
+echo '	\$(RM) model.o \$(MODEL_LIB) \$(SXMODEL_LIB) \$(EXEC_BIN) ; \'
+echo '	echo "Rebuilding the AA_make files" ; \'
+echo '	cd ..  ; ../UTIL/fait_AA_make ; echo " " ; \'
+echo '	echo "THE ins_make COMMAND in modipsl/util MUST BE RERUN PLEASE DO SO BEFORE gmake" ; \'
+echo '	echo "========================================== " ; \'
+echo '	../../util/ins_make ; echo " " ;  false ; exit ; }'
+exec > /dev/null
+
Index: /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_config
===================================================================
--- /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_config	(revision 1909)
+++ /branches/DEV_r1879_FCM/NEMOGCM/UTIL/fait_config	(revision 1909)
@@ -0,0 +1,171 @@
+#!/bin/ksh
+######################################################
+# Author : Rachid benshila for ESOPA
+# Contact : opatlod@lodyc.jussieu.fr
+#
+# This script aims to create the OPA/WORK directory 
+# with links to target directories for the sources
+# and to link in the WORK the BB_make and BB_make.ldef 
+# associated  to a chosen configuration
+#
+######################################################
+
+###################################
+#                                 #
+# Beginning of user modifications #
+#                                 #
+###################################
+#- Config name ---
+# To add a new configuration called NAME you have to change this script
+# 1. Add your configuration in LIST
+# 2. Add the directories needed for this config : set -A DIR_NAME DIR1 DIR2 ...
+# 3. Run fait_config NAME
+# If there is no directory config/NAME/scripts, and in this no BB_make.ldef, 
+# the config/ORCA2_LIM directory is copied under NAME
+#
+# Example 1 : in order to create a GYRE_TRC configuration :
+# 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nGYRE_TRC"
+# 2. In this script, add set -A DIR_GYRE_TRC OPA_SRC LIM_SRC_3 TOP_SRC C1D_SRC, take care of the syntax
+# 3. Run fait_config GYRE_TRC
+# Example 2 : in order to create an OFFLINE_TRC configuration :
+# 1. In this script, change LIST to LIST="ORCA2_LIM \nGYRE \nOFFLINE_TRC"
+# 2. In this script, add set -A DIR_OFFLINE_TRC OFF_SRC TOP_SRC, take care of the syntax
+# 3. Run fait_config OFFLINE_TRC
+# Example 2 : in order to use LIM3, just change LIM_SRC_2 in LIM_SRC_3
+
+LIST="ORCA2_LIM \nGYRE \nGYRE_LOBSTER \nORCA2_LIM_PISCES \nORCA2_OFF_PISCES \nPOMME \nIPSLCM5 \nIPSLCM5_LOOP"
+set -A DIR_ORCA2_LIM OPA_SRC LIM_SRC_2 C1D_SRC NST_SRC
+set -A DIR_GYRE OPA_SRC LIM_SRC_2 C1D_SRC 
+set -A DIR_GYRE_LOBSTER OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+set -A DIR_ORCA2_LIM_PISCES OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC NST_SRC 
+set -A DIR_ORCA2_OFF_PISCES OFF_SRC TOP_SRC
+set -A DIR_POMME OPA_SRC LIM_SRC_2 C1D_SRC 
+set -A DIR_IPSLCM5 OPA_SRC LIM_SRC_2 C1D_SRC
+set -A DIR_IPSLCM5_LOOP OPA_SRC LIM_SRC_2 C1D_SRC TOP_SRC
+set -A DIR_IPSL_ESM_v2 OPA_SRC LIM_SRC_2 C1D_SRC
+
+###################################
+#                                 #
+#    End of user modifications    #
+#                                 #
+###################################
+
+
+#- Some tests ---
+d_n=$(dirname $0); b_n=$(basename $0);
+
+if   [ ${#} -gt 1 ]; then
+    echo 'Only one configuration can be specified in:' 1>&2;
+    echo $LIST 1>&2;
+    exit 3;
+elif [ ${#} -eq 1 ]; then
+     m_n="${1}"
+elif [ ${#} -eq 0 ]; then
+    echo 'You must specify one configuration in :' 1>&2;
+    echo $LIST 1>&2;
+    echo 'You can also complete fait_config to add a new one'
+    exit 3;
+fi
+
+#- Create the WORK --
+d_m=`find ${d_n}/.. -name NEMO`  ;
+[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK;
+cd ${d_m}/WORK
+
+#- Clean links and librairies
+[ -f Makefile ] && gmake clean 
+[ -n "`\ls`" ] && \rm -rf * 
+
+#- Find the number of directories ---
+eval NDIR=\${#DIR_${m_n}[*]}
+
+#- Build a working array TAB containing the directories ---
+i=0
+while [ i -lt $NDIR ]
+do
+    eval  TAB[i]=\${DIR_${m_n}[i]}
+    let i=i+1
+done
+
+#- Creating the good links, at first on OPA_SRC ---
+if [ ${#TAB[*]} -ne 0 ] ; then
+    echo " Creating NEMO/WORK = ${TAB[*]} for ${m_n}"
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*.[Ffh]90 .
+	[ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../OPA_SRC/*/*.[Ffh]90 . && break
+	let i=$i+1
+    done
+
+    i=0
+    while [ i -lt $NDIR ]
+    do
+      if [ "${TAB[i]}" = "LIM_SRC_3" ]; then
+	  ln -sf ../LIM_SRC_3/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "LIM_SRC_2" ]; then
+	  ln -sf ../LIM_SRC_2/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "C1D_SRC" ]; then
+	  ln -sf ../C1D_SRC/*.[Ffh]90 .  
+      
+      elif [ "${TAB[i]}" = "TOP_SRC" ]; then
+	  ln -sf ../TOP_SRC/*.[Ffh]90 .       
+	  ln -sf ../TOP_SRC/*/*.[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                    
+	  [ -f  agrif_top_interp.F90 ] && \rm agrif_top_interp.F90                    
+	  [ -f  agrif_top_sponge.F90 ] && \rm agrif_top_sponge.F90                    
+	  [ -f  agrif_top_update.F90 ] && \rm agrif_top_update.F90                    
+	  ln -sf ../NST_SRC/*.[Ffh]90 .
+      
+      elif [ "${TAB[i]}" = "OFF_SRC" ]; then  
+	  ln -sf ../OFF_SRC/*.[Ffh]90 .
+	  ln -sf ../OFF_SRC/*/*.[Ffh]90 .
+      fi
+      let i=$i+1
+    done
+
+    [ ! -d ../../../config/${m_n} ] && \cp -R ../../../config/ORCA2_LIM ../../../config/${m_n} 
+    ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; 
+    ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ;
+
+else
+
+    echo "Configuration "${m_n}" not supported" 1>&2
+    echo 'Make your choice in :' 1>&2
+    echo $LIST 1>&2
+    echo 'You can also complete fait_config to add a new one'
+    exit 1
+
+fi 
+
+#- Building the standard list of source files ---
+cat >.patron <<"EOF" 
+CVS
+SRC_PARAM
+SRC_FILE_LIST
+tmplist
+AA_make
+KEY_CPP
+Makefile
+*?.o
+ i.?*
+*?.L
+.patron
+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 /^P_P/\!d -e "s/P_P = //" AA_make.ldef > KEY_CPP;    
+
+#- Save new configuration an d directories names ---
+print ${m_n} ${TAB[*]} >.config 
+
+exit 0;
