#!/bin/csh -f #==================================== # If the cice binary is passed via the --exe argument and the file exists, # copy it into the run directory and don't build the model. set dohelp = 0 set directmake = 0 set target = "UnDEFineD" set ciceexe = "UnDEFineD" if ($#argv == 0) then # continue, standard way to build else # -h, --help if ("$1" == "-h" || "$1" == "--help") then set dohelp = 1 # --exe else if ("$1" == "--exe") then if ($#argv > 2) then echo "${0}: ERROR: --exe ciceexe without other arguments is required" exit -99 endif set ciceexe = $2 echo "${0}: ciceexe = ${ciceexe}" if (-e ${ciceexe}) then source ./cice.settings source ${ICE_CASEDIR}/env.${ICE_MACHCOMP} -nomodules || exit 2 if !(-d ${ICE_RUNDIR}) mkdir -p ${ICE_RUNDIR} cp -p ${ciceexe} ${ICE_RUNDIR}/cice echo "`date` ${0}:${ICE_CASENAME} build copied ${ciceexe}" >> ${ICE_CASEDIR}/README.case if ( ${ICE_TEST} != ${ICE_SPVAL} ) then echo "#---" >! ${ICE_CASEDIR}/test_output echo "COPY ${ICE_TESTNAME} build" >> ${ICE_CASEDIR}/test_output echo "PEND ${ICE_TESTNAME} run" >> ${ICE_CASEDIR}/test_output endif exit 0 endif # direct make with target else set directmake = 1 set target = "$*" endif endif if (${dohelp} == 1) then cat << EOF1 NAME cice.build [-h,--help] [make arguments] [target] SYNOPSIS -h || --help [make arguments] [target] DESCRIPTION --help, -h : help [make arguments] [target] : specify make arguments and target EXAMPLES cice.build will build the model using the standard approach with all the bells and whistles. This is recommended. cice.build --help will show cice.build help cice.build [target] will call gmake directly and make the target cice.build clean is an example of a targeted build cice.build targets is an example of a targeted build that shows the valid Makefile targets cice.build --version will call make directly and pass --version as an argument to make cice.build [make arguments] [target] will call make directly and pass arguments and/or a target to make ADDITIONAL INFORMATION The argument implementation supports -h or --help as a first argument. Otherwise, it passes all other arguments directly to make and calls it directly. In this mode, most of the cice.build script features are by-passed. The recommended way to run the script is without arguments. SEE ALSO User Documentation at https://github.com/cice-consortium/cice/ EOF1 exit -99 endif #==================================== source ./cice.settings source ${ICE_CASEDIR}/env.${ICE_MACHCOMP} || exit 2 if (${ICE_MACHINE} != ${ICE_MACHINE_MACHNAME}) then echo "WARNING, is ICE_MACHINE setting OK, ${ICE_MACHINE}, ${ICE_MACHINE_MACHNAME}" endif if (${ICE_ENVNAME} != ${ICE_MACHINE_ENVNAME}) then echo "WARNING, is ICE_ENVNAME setting OK, ${ICE_ENVNAME}, ${ICE_MACHINE_ENVNAME}" endif echo " " echo "${0}:" set stamp = `date '+%y%m%d-%H%M%S'` set ICE_BLDLOG_FILE = "cice.bldlog.${stamp}" set quiet = ${ICE_QUIETMODE} if !(-d ${ICE_RUNDIR}) mkdir -p ${ICE_RUNDIR} if !(-d ${ICE_OBJDIR}) mkdir -p ${ICE_OBJDIR} cd ${ICE_OBJDIR} if (${ICE_IOTYPE} == 'netcdf') then set IODIR = io_netcdf setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DUSE_NETCDF" else if (${ICE_IOTYPE} =~ pio*) then set IODIR = io_pio2 setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DUSE_NETCDF" else set IODIR = io_binary endif if (${ICE_SNICARHC} == 'false') then setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DNO_SNICARHC" endif ### List of source code directories (in order of importance). cat >! Filepath << EOF ${ICE_SANDBOX}/cicecore/drivers/${ICE_DRVOPT} ${ICE_SANDBOX}/cicecore/cicedyn/dynamics ${ICE_SANDBOX}/cicecore/cicedyn/general ${ICE_SANDBOX}/cicecore/cicedyn/analysis ${ICE_SANDBOX}/cicecore/cicedyn/infrastructure ${ICE_SANDBOX}/cicecore/cicedyn/infrastructure/io/$IODIR ${ICE_SANDBOX}/cicecore/cicedyn/infrastructure/comm/${ICE_COMMDIR} ${ICE_SANDBOX}/cicecore/shared ${ICE_SANDBOX}/icepack/columnphysics EOF if !($?ICE_MACHINE_BLDTHRDS) then set ICE_MACHINE_BLDTHRDS = 1 endif if (${directmake} == 0) then set target = ${ICE_TARGET} endif if (${directmake} == 1) then echo "make ${target}" ${ICE_MACHINE_MAKE} -j ${ICE_MACHINE_BLDTHRDS} VPFILE=Filepath EXEC=${ICE_RUNDIR}/cice \ -f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} \ DEPFILE=${ICE_CASEDIR}/makdep.c ${target} set bldstat = ${status} if (${bldstat} != 0) then echo "${0}: targeted make FAILED" exit -99 endif exit 0 endif echo " " echo ICE_GRID = ${ICE_GRID} echo ICE_NTASK = ${ICE_NTASKS} echo ICE_NTHRD = ${ICE_NTHRDS} echo "ICE_CPPDEFS = ${ICE_CPPDEFS}" echo "Filepath = " cat ${ICE_OBJDIR}/Filepath echo " " echo "building cice > ${ICE_OBJDIR}/${ICE_BLDLOG_FILE}" if (-e ${ICE_BLDLOG_FILE}) rm ${ICE_BLDLOG_FILE} if (${ICE_CLEANBUILD} == 'true') then echo "gmake clean" if (${quiet} == "true") then ${ICE_MACHINE_MAKE} VPFILE=Filepath EXEC=${ICE_RUNDIR}/cice \ -f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} \ DEPFILE=${ICE_CASEDIR}/makdep.c clean >& ${ICE_BLDLOG_FILE} else ${ICE_MACHINE_MAKE} VPFILE=Filepath EXEC=${ICE_RUNDIR}/cice \ -f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} \ DEPFILE=${ICE_CASEDIR}/makdep.c clean |& tee ${ICE_BLDLOG_FILE} endif endif echo "gmake cice" if (${quiet} == "true") then echo " quiet mode on... patience" ${ICE_MACHINE_MAKE} -j ${ICE_MACHINE_BLDTHRDS} VPFILE=Filepath EXEC=${ICE_RUNDIR}/cice \ -f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} \ DEPFILE=${ICE_CASEDIR}/makdep.c ${target} >& ${ICE_BLDLOG_FILE} set bldstat = ${status} else ${ICE_MACHINE_MAKE} -j ${ICE_MACHINE_BLDTHRDS} VPFILE=Filepath EXEC=${ICE_RUNDIR}/cice \ -f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} \ DEPFILE=${ICE_CASEDIR}/makdep.c ${target} |& tee ${ICE_BLDLOG_FILE} set bldstat = ${status} endif if !(-d ${ICE_LOGDIR}) mkdir -p ${ICE_LOGDIR} cp -p ${ICE_BLDLOG_FILE} ${ICE_LOGDIR}/ echo " " # special effort to trap and highlight circular dependencies errors set circularstat = `grep "make: Circular" ${ICE_BLDLOG_FILE} | wc -l` if (${circularstat} > 0) then echo "${0}: ERROR: Circular dependencies found" grep "make: Circular" ${ICE_BLDLOG_FILE} if (-e ${ICE_RUNDIR}/cice) then echo "${0}: Deleting cice executable" rm ${ICE_RUNDIR}/cice endif set bldstat = 55 endif if (${bldstat} != 0) then echo "${0}: COMPILE FAILED, see" echo " cat ${ICE_OBJDIR}/${ICE_BLDLOG_FILE}" if (${quiet} == "true" && ${circularstat} == 0) then tail -10 ${ICE_OBJDIR}/${ICE_BLDLOG_FILE} endif if ( ${ICE_TEST} != ${ICE_SPVAL} ) then # This is a test case. Write output to test_output file echo "#---" >! ${ICE_CASEDIR}/test_output echo "FAIL ${ICE_TESTNAME} build" >> ${ICE_CASEDIR}/test_output echo "FAIL ${ICE_TESTNAME} run" >> ${ICE_CASEDIR}/test_output endif exit 99 endif echo "`date` ${0}:${ICE_CASENAME} build completed ${ICE_BLDLOG_FILE}" >> ${ICE_CASEDIR}/README.case echo "${0}: COMPILE SUCCESSFUL, ${ICE_LOGDIR}/${ICE_BLDLOG_FILE}" if ( ${ICE_TEST} != ${ICE_SPVAL} ) then echo "#---" >! ${ICE_CASEDIR}/test_output echo "PASS ${ICE_TESTNAME} build" >> ${ICE_CASEDIR}/test_output echo "PEND ${ICE_TESTNAME} run" >> ${ICE_CASEDIR}/test_output endif