Index: LMDZ5/branches/LMDZ5-DOFOCO/makelmdz
===================================================================
--- LMDZ5/branches/LMDZ5-DOFOCO/makelmdz	(revision 1934)
+++ LMDZ5/branches/LMDZ5-DOFOCO/makelmdz	(revision 2071)
@@ -25,4 +25,6 @@
 fcm_path=none
 cosp=false
+sisvat=false
+rrtm=false
 
 # guess a default 'arch'
@@ -30,15 +32,7 @@
 ## try to recognise machine and infer arch from it
 machine=`hostname`
-if [[ "$machine" == "brodie" ]]
-then
-  arch="SX8_BRODIE"
-fi
-if [[ "${machine:0:6}" == "vargas" ]]
-then
-  arch="PW6_VARGAS"
-fi
-if [[ "${machine:0:6}" == "ciclad" ]]
-then
-  arch="AMD64_CICLAD"
+if [[ "${machine:0:3}" == "ada" ]]
+then
+  arch="X64_ADA"
 fi
 if [[ "${machine:0:7}" == "platine" ]]
@@ -165,11 +159,12 @@
 	  CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
 
-      "-adjnt")
-	  echo "not operational ... work to be done here ";exit
-	  opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
-	  optim="$optim -Dadj" ; shift ;;
-
       "-cosp")
           cosp="$2" ; shift ; shift ;;
+      
+      "-sisvat")
+          sisvat="$2" ; shift ; shift ;;
+      
+      "-rrtm")
+          rrtm="$2" ; shift ; shift ;;
       
       "-mem")
@@ -276,4 +271,8 @@
 LIB="$LIB  ${archfileopt}"
 
+# add Include files defined in arch.fcm file for pre-processing
+archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
+for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
+
 if [[ "$physique" != "nophys" ]]
 then
@@ -306,5 +305,5 @@
   FLAG_PARA=''
 else
-  FLAG_PARA="par"
+  FLAG_PARA="$paramem"
 fi
 
@@ -351,28 +350,27 @@
 fi
 
-if [[ "$veget" == "orchidee2.0" ]]
-then
-# orchidee2.0 : 
-# Compile with ORCHIDEE 2.0 (or more recent)
+
+#==============================================================================
+if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
+then
+
+   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
    CPP_KEY="$CPP_KEY CPP_VEGET"
-   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
-   LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}orchidee "
-elif [[ "$veget" == "orchidee1.9" ]]
-then
-# orchidee1.9 : 
-# Compile with ORCHIDEE version up to the inclusion of OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
-   CPP_KEY="$CPP_KEY CPP_VEGET ORCHIDEE_NOOPENMP"
-   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
-   LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob"
-elif [[ "$veget" == "true" ]]
-then
-# true : 
-# Obsolete, for backward compatibility. To be used with ORCHIDEE tag 1.9-1.9.6
-# For this case, cpp flag ORCHIDEE_NOOPENMP must be added to the makelmdz_fcm arguments
-   CPP_KEY="$CPP_KEY CPP_VEGET"
-   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
-   LIB="${LIB} -L${ORCH_LIBDIR} -l${LIBPREFIX}sechiba -l${LIBPREFIX}parameters -l${LIBPREFIX}stomate -l${LIBPREFIX}parallel -l${LIBPREFIX}orglob"
-elif [[ "$veget" != "false" ]]
-then
+# temporary, for Orchidee versions 1.9.* (before openmp activation)
+   if [[ "$veget" == "orchidee1.9" ]] ; then
+      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
+   fi
+   if [[ "$veget" == "orchidee2.0" ]] ; then
+      orch_libs="sechiba parameters stomate parallel orglob orchidee"
+   else
+      orch_libs="sechiba parameters stomate parallel orglob"
+   fi
+   LIB="${LIB} -L${ORCH_LIBDIR}"
+   for lib in ${orch_libs} ; do
+      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
+         LIB="${LIB} -l${LIBPREFIX}$lib "
+      fi
+   done
+elif [[ "$veget" != "false" ]] ; then
    echo "Option -v $veget does not exist"
    echo "Use ./makelmdz -h for more information"
@@ -380,4 +378,5 @@
 fi
 
+#===============================================================================
 if [[ $io == ioipsl ]]
 then
@@ -385,4 +384,10 @@
    INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
    LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
+elif [[ $io == xios ]]
+then
+   # For now, xios implies also using ioipsl
+   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
+   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
+   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
 fi
 
@@ -396,4 +401,15 @@
    INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
 fi
+
+if [[ "$sisvat" == "true" ]]
+then
+   CPP_KEY="$CPP_KEY CPP_SISVAT"
+fi
+
+if [[ "$rrtm" == "true" ]]
+then
+   CPP_KEY="$CPP_KEY CPP_RRTM"
+fi
+
 
 INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
@@ -453,66 +469,21 @@
 ########################################################################
 
-dimension=`echo $dim | wc -w`
-echo dimension $dimension
-
-if (( $dimension == 3 ))
-then
-  cd $LIBFGCM/grid
-  \rm fxyprim.h
-  cp -p fxy_${grille}.h fxyprim.h
+if (( $dimc == 3 )) ; then
+   cd $LIBFGCM/grid
+   \rm fxyprim.h
+   cp -p fxy_${grille}.h fxyprim.h
+   filtre="FILTRE=$filtre"
+   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
+elif (( $dimc == 2 )) ; then
+   filtre="FILTRE= L_FILTRE= "
+   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
+elif (( $dimc == 1 )) ; then
+   CPP_KEY="$CPP_KEY CPP_1D"
+   filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique "
+   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
 else
-  echo "Probleme dans les dimensions de la dynamique !!"
-  echo "Non reactive pour l'instant !!!"
-fi
-
-######################################################################
-# Gestion du filtre qui n'existe qu'en 3d.
-######################################################################
-
-if (( `expr $dimc \> 2` == 1 ))
-then
-   filtre="FILTRE=$filtre"
-else
-   filtre="FILTRE= L_FILTRE= "
-fi
-echo MACRO FILTRE $filtre
-
-echo $dimc
-
-######################################################################
-# Creation du suffixe de la configuration
-######################################################################
-
-
-SUFF_NAME=_${dim_full}
-SUFF_NAME=${SUFF_NAME}_phy${physique}
-
-if [[ "$parallel" != "none" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_para
-  DYN=dyn${dimc}d${paramem}
-  if [[ "$paramem" == "mem" ]]
-  then
-   SUFF_NAME=${SUFF_NAME}_${paramem}
-  fi
-else
-  SUFF_NAME=${SUFF_NAME}_seq
-  DYN=dyn${dimc}d
-fi
-
-if [[ $veget != "false" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_orch
-fi
-
-if [[ $couple != "false" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_couple
-fi
-
-if [[ $chimie == "INCA" ]]
-then
-  SUFF_NAME=${SUFF_NAME}_inca
-fi
+   echo Dimension dimc=$dimc pas prevu ; exit
+fi
+
 
 cd $LMDGCM
@@ -531,7 +502,8 @@
 ########################################################################
 cd $LMDGCM
+
 find libf -name '*.[Fh]' -print > tmp77
 find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
-find libf -name '*.[Fh90]' -print >> tmp90
+find libf -name '*.F90' -print >> tmp90
 
 if [[ ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]]
@@ -557,13 +529,11 @@
 then
   source_code=${code}.F90
+elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
+  source_code=${code}.F90
 fi
 
 # library directory name:
-if [[ "$parallel" == "none" ]]
-then 
-  nomlib=${arch}_${physique}_${dim_full}_${grille}_${compil_mod}
-else
-  nomlib=${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_${FLAG_PARA}
-fi
+nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'`
+echo $nomlib
 
 if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
@@ -585,5 +555,5 @@
   INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
 fi
-INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
+INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
 
 # ranlib utility (check it exists or else default to ls)
@@ -645,5 +615,5 @@
 DIM=$dimc \
 FLAG_PARA=$FLAG_PARA \
-L_ADJNT="$adjnt" \
+L_ADJNT=$adjnt \
 L_COSP="$lcosp" \
 L_CHIMIE="$libchimie" \
@@ -660,4 +630,5 @@
 PROG=$code
 
+
 if [[ -r $LIBFGCM/grid/dimensions.h ]]
 then
