#!/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 # Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode resol_atm=144x142x79 # Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025) resol_oce=ORCA1 # Version of ice model lim2/lim3 icemodel=lim3 # Coupled with ocean biogeochemistry (y/n) oceanbio=y # Version ESM CO2: CO2 interactif ocean/atmosphere (y/n) esmco2=n # Optimization mode # optmode=prod/dev/debug optmode=prod # fcm_arch fcm_arch=default # Default values to be overritten parallel=mpi_omp export fcm_arch parallel xios full_flag="" full_nemo=n # Default netcdf_lib is used for XIOS but can be change by argument netcdf_lib="" # Output text file for compilation of each component outfile=$submitdir/out_compile_ipslcm6 rm -f $outfile; echo > $outfile echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo #### Read arguments # Loop over all arguments to modify default set up while (($# > 0)) ; do case $1 in "-h") cat <> $outfile echo " resol_atm=${resol_atm}, resol_oce=${resol_oce}, icemodel=${icemodel}, withpisces=${pisces}" >> $outfile echo " esmco2=${esmco2}" >> $outfile echo " optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $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 ada*) fcm_arch=X64_ADA;; irene*) fcm_arch=X64_IRENE;; asterix*|obelix*) fcm_arch=ifort_LSCE;; 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.1 Compile ioipsl cd $modipsl/modeles/IOIPSL echo; echo "NOW COMPILE IOIPSL" echo >> $outfile ; echo " NOW COMPILE IOIPSL" >> $outfile # Check if compilation with fcm is included in IOIPSL if [ ! -f makeioipsl_fcm ] ; then echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL." echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now." exit fi echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag >> $outfile 2>&1 # Test if compiling succeded if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP" exit fi ## 2.2 Compile oasis3-mct oasis_dir=$modipsl/oasis3-mct echo; echo "NOW COMPILE OASIS3-MCT" echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT" >> $outfile cd $oasis_dir/util/make_dir ; cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc ; make -f TopMakefileOasis3 ; ## 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 ${netcdf_lib} --job 4 $full_flag >> $outfile ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag >> $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.4 Compile orchidee cd $modipsl/modeles/ORCHIDEE echo; echo "NOW COMPILE ORCHIDEE" echo >> $outfile ; echo " NOW COMPILE ORCHIDEE" >> $outfile echo ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver >> $outfile 2>&1 # Test if compiling finished if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP" exit fi ## 2.5 Compile NEMO nemo_root=$modipsl/modeles/NEMOGCM/CONFIG if [ ${icemodel} == lim2 ] ; then addkeys="key_lim2_vp key_diahth key_oasis3" delkeys="key_nosignedzero key_mpp_rep" else addkeys="key_top key_pisces key_age key_cfc key_cpl_carbon_cycle key_gas key_oasis" if [ ${oceanbio} == y ] ; then if [ ${esmco2} == y ] ; then delkeys="key_nosignedzero key_mpp_rep" else delkeys="key_nosignedzero key_mpp_rep key_cpl_carbon_cycle key_gas" fi else delkeys="key_nosignedzero key_mpp_rep key_top key_pisces key_cfc key_age key_cpl_carbon_cycle key_gas" fi fi if [ ${oceanbio} == n ] ; then echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES" echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES" >> $outfile else echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES" echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES" >> $outfile fi echo >> $outfile ; echo cd $nemo_root >> $outfile echo >> $outfile ; echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/arch-${fcm_arch}.fcm ../ARCH/. >> $outfile echo >> $outfile cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/. if [ ${resol_oce} == ORCA2 ] ; then cfg_wrk=ORCA2_LIM_PISCES ; fi if [ ${resol_oce} == ORCA1 ] ; then cfg_wrk=ORCA1_LIM3_PISCES ; fi if [ ${resol_oce} == ORCA025 ] ; then cfg_wrk=ORCA025_LIM3_PISCES ; fi echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/ >> $outfile echo >> $outfile cp $mysrc_path/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/ if [ $full_nemo == y ] ; then echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean >> $outfile echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys" del_key "$delkeys" >> $outfile echo >> $outfile ./makenemo -m ${fcm_arch} -n $cfg_wrk clean >> $outfile 2>&1 ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys" del_key "$delkeys" >> $outfile 2>&1 else echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys" del_key "$delkeys" >> $outfile echo >> $outfile ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys" del_key "$delkeys" >> $outfile 2>&1 fi # Test if compiling finished if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP" exit fi echo echo "copy nemo executable to modipsl/bin" if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] ; then cp $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa ; fi if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] && [ ${esmco2} == y ] ; then cp $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa.esm ; fi ## 2.6 Compile LMDZ for regular latlon configuration cd $modipsl/modeles/LMDZ # Compile LMDZ regular lat-lon exectuable echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}" >> $outfile echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm >> $outfile 2>&1 # Test if compiling finished if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP" exit fi # Compile ce0l initialization program for LMDZ regular lat-lon exectuable echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}" >> $outfile echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l >> $outfile 2>&1 # Test if compiling finished if [[ $? != 0 ]] ; then echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP" exit fi # Find executable suffix if [ $parallel == seq ] || [ $parallel == none ] ; then suffix=_${resol_atm}_phylmd_seq_orch else suffix=_${resol_atm}_phylmd_para_mem_orch fi echo suffix = $suffix # Move executables to modipsl/bin folder echo "Move gcm.e and ce0l executable to modipsl/bin" if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm}_${optmode}.e ; fi if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ; then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm}_${optmode}.e ; fi echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile echo; echo "ALL COMPILING FINISHED" date exit