#!/bin/bash #set -vx # Default options # # # date #### 1 Set up the compiling options #### Define some directories submitdir=$( pwd ) modipsl=$submitdir/../.. arch_path=$submitdir/ARCH mysrc_path=$submitdir/SOURCES #### Set default options # Coupled with ocean biogeochemistry (y/n) cpltop=WithTOP # Coupled with ocean biogeochemistry (y/n) cplmode=online # Optimization mode # optmode=prod/dev/debug optmode=prod # fcm_arch fcm_arch=default export fcm_arch xios full_nemo=n full_xios="" # Output text file for compilation of each component datestr=`LC_ALL=C date +"%Y%m%dT%H%M"` outfile=$submitdir/out_compile_nemo.$datestr echo > $outfile echo; echo "Text output from compilation will be stored in file out_compile_nemo.$datestr"; echo #### Read arguments # Loop over all arguments to modify default set up while (($# > 0)) ; do case $1 in "-h") cat <> $outfile echo " WithTracer=${cpltop}, coupled_mode=${cplmode}" >> $outfile echo " optmode = $optmode, fcm_arch = $fcm_arch " >> $outfile echo " full_xios=$full_xios, full_nemo=$full_nemo," >> $outfile echo >> $outfile ### Read host dependent default values ### These variables will not be changed if they were set as argument ###./host.sh $host # Later : Following lines should be set in host.sh file # begin host.sh if [ $fcm_arch == default ] ; then # Find out current host and source specific paths and commands for the host case $( hostname -s ) in jean-zay*) fcm_arch=X64_JEANZAY;; irene170|irene171|irene190|irene191|irene192|irene193) fcm_arch=X64_IRENE;; irene172|irene173|irene194|irene195) fcm_arch=X64_IRENE-AMD;; ciclad*|climserv*) fcm_arch=ifort_CICLAD;; *) echo Current host is not known. You must use option -arch to specify which architecuture files to use. echo Exit now. exit esac fi # Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch. # The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement. if [ -f ARCH/arch-${fcm_arch}.env ] ; then echo >> $outfile echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components" echo "Note that this new environement might be kept after compilation." echo "If this is the case, source again your personal environment after compilation. " echo " Personal module list before sourcing of ARCH/arch.env file:" >> $outfile module list >> $outfile 2>&1 # Make a link to this file, to be used also in config.card rm -f ARCH/arch.env ln -s arch-${fcm_arch}.env ARCH/arch.env # Source the file source ARCH/arch.env >> $outfile 2>&1 echo >> $outfile echo " New module list after sourcing of ARCH/arch.env file:" >> $outfile module list >> $outfile 2>&1 fi #### 2 Do the compilation ## 2.3 Compile xios cd $modipsl/modeles/XIOS echo; echo "NOW COMPILE XIOS" echo >> $outfile ; echo " NOW COMPILE XIOS" >> $outfile echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios >> $outfile ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios >> $outfile 2>&1 # Test if compiling succeded if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP" exit fi # Move executables to modipsl/bin if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe else echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP" exit fi ## 2.5 Compile NEMO nemo_root=$modipsl/modeles/NEMO cfg_ref=ORCA2_ICE_PISCES cfg_wrk=ORCA_ICE_TRC addkeys="key_top key_si3" delkeys="" if [ ${cplmode} == offline ] ; then cfg_ref=ORCA2_OFF_TRC cfg_wrk=ORCA_OFF_TRC delkeys="key_si3" fi if [ ${cpltop} == WithoutTOP ] ; then cfg_wrk=ORCA_ICE delkeys="key_top" fi echo >> $outfile ; echo cd $nemo_root >> $outfile echo >> $outfile ; echo cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/. >> $outfile echo >> $outfile cd $nemo_root ; cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/. echo >> $outfile # creation of config echo >> $outfile ; echo cd $nemo_root >> $outfile echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys" del_key "$delkeys" >> $outfile echo >> $outfile cd $nemo_root ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys" del_key "$delkeys" >> $outfile 2>&1 # Copy of specfic source files echo >> $outfile ; echo cp $mysrc_path/*.*90 $nemo_root/cfgs/$cfg_wrk/MY_SRC/. >> $outfile echo >> $outfile cp $mysrc_path/*.*90 $nemo_root/cfgs/$cfg_wrk/MY_SRC/. if [ $full_nemo == y ] ; then # To make a full compilation, first make a clean to remove all files produced during previous compilation echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean >> $outfile echo >> $outfile ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean >> $outfile 2>&1 fi echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8 >> $outfile echo >> $outfile ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8 >> $outfile 2>&1 # Test if compiling finished if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP" exit fi echo >> $outfile echo "Move nemo executable to modipsl/bin" >> $outfile echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin >> $outfile ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin >> $outfile echo >> $outfile if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${cplmode}_${optmode}.exe else echo "ERROR gcm${suffix} executable does not exist." echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP" exit fi echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile echo ls -lrt modipsl/bin >> $outfile ls -lrt $modipsl/bin >> $outfile echo; echo "ALL COMPILING FINISHED" ; echo echo "Executables are found in modipsl/bin" echo "Check that executable names correspond with the name set in config.card before launching the job" echo ls -lrt modipsl/bin ls -lrt $modipsl/bin date exit