#!/bin/csh -f #================================================================================ # Running this script generate machine specific build, run and # long term archiving scripts in this directory #================================================================================ if ($#argv < 1) then cat << EOF1 NAME configure - configures the model for a given resolution, component set and machine. The environment variables used by the configuration process are contained in env_conf and env_mach.machine in this directory. SYNOPSIS standard usage ======================================================== configure [-mach machine] [-cleanall] [-cleanmach mach] [-addmach machine] help option ======================================================== configure -help EOF1 exit -1; endif set i = `echo $argv[1]|cut -c2-` if($i == "help") then cat << EOF2 NAME configure - configures the model for a given resolution, component set and machine. The environment variables used by the configuration process are contained in env_conf and env_mach.machine in this directory. SYNOPSIS configure [-mach machine] [-addmach machine] [-cleanall] [-cleanmach mach] [-help] OPTIONS -mach machine Where "machine" specifies the machine name that the scripts will be configured for. This assumes that a file of the name env_mach.machine already exists in this directory. If it does not, first enter the command: configure -addmach machine to generate this file. Multiple machines can be configured in this directory. See below for current valid supported machines. -addmach machine Adds a machine environment variable file to the case script directory . This command needs to be run before configure is run for this machine. -cleanmach machine Removes all machine related files related to "machine" but keeps the directories Buildnml_prestage/, Buildexe/ Buildlib/ and run and build scripts for other machines. -cleanall Removes all directories and files produced by running configure so that configure can be run again -help Requests more extensive documentation SUPPORT DETAILS EOF2 source ./env_run $UTILROOT/Tools/check_machine -list || exit -1 exit; endif while ( 1 ) if ( $#argv < 1 ) break; set i = $argv[1]; switch ( $i ) case "-cleanall" rm -rf Build* >& /dev/null rm -f *.build >& /dev/null rm -f *.build.[0-9]* >& /dev/null rm -f *.run >& /dev/null rm -f *.run.[0-9]* >& /dev/null rm -f *.l_archive >& /dev/null rm -f *.l_archive.[0-9]* >& /dev/null rm -f .cache/* >& /dev/null echo "Successfully cleaned case" exit 0 breaksw case "-cleanmach" shift argv set MACH = $argv[1] if !($?MACH) then echo "ERROR: must specify machine name" exit -1 endif source ./env_run || exit -1 $UTILROOT/Tools/check_machine ${MACH} if ($status != 0) exit -1 #v echo "removing .cache/\*$MACH\* files" rm -f .cache/*${MACH}* foreach i (*.${MACH}.*[A-Za-z]) set id = "`date +%y%m%d-%H%M%S`" #v echo "moving $i to $i.$id" mv $i $i.${id} end echo "Successfully cleaned scripts for $MACH" exit 0 breaksw case "-addmach" shift argv setenv MACH $argv[1] if !($?MACH) then echo "ERROR: must specify machine name" exit -1 endif if (-f env_mach.${MACH}) then echo "ERROR: machine environment file env_mach.${MACH} already exists" exit -1 endif if (-f Macros.${MACH}) then echo "ERROR: machine environment file Macros.${MACH} already exists" exit -1 endif source ./env_run || exit -1 $UTILROOT/Tools/check_machine ${MACH} if ($status != 0) exit -1 cp ${UTILROOT}/Machines/env.*${MACH} env_mach.${MACH} if ($status != 0) then echo "ERROR: cannot copy file env_mach.${MACH}" exit -1 endif source env_conf source env_mach.${MACH} if (-f ${BLDROOT}/Macros.${OS}) then cat ${BLDROOT}/Macros.${OS} > Macros.${MACH} else echo "ERROR: cannot get file ${BLDROOT}/Macros.${OS}" exit -1 endif if (-f ${UTILROOT}/Machines/Macros.${OS}.${MACH}) then cat ${UTILROOT}/Machines/Macros.${OS}.${MACH} >> Macros.${MACH} endif source ${UTILROOT}/Machines/pes_setup if(-f ${UTILROOT}/Machines/pes_setup.${MACH}) then source ${UTILROOT}/Machines/pes_setup.${MACH} endif if ($?PESFILE) then if(-f ${PESFILE}) then source ${PESFILE} endif endif cat >! env_pes.$MACH << EOF #!/bin/csh -f #--- component task/thread settings -------- # users can change these values, then run # ./configure -cleanmach $MACH # ./configure -mach $MACH # to reset the pes for the run #------------------------------------------- setenv NTASKS_ATM $ntasks_atm setenv NTHRDS_ATM $nthrds_atm setenv NTASKS_LND $ntasks_lnd setenv NTHRDS_LND $nthrds_lnd setenv NTASKS_ICE $ntasks_ice setenv NTHRDS_ICE $nthrds_ice setenv NTASKS_OCN $ntasks_ocn setenv NTHRDS_OCN $nthrds_ocn setenv NTASKS_CPL $ntasks_cpl setenv NTHRDS_CPL $nthrds_cpl EOF echo "Successfully added $MACH" exit 0 breaksw case "-mach" shift argv source ./env_run || exit -1 setenv MACH $argv[1] if !($?MACH) then echo "ERROR: must specify machine name" exit -1 endif $UTILROOT/Tools/check_machine ${MACH} if ($status != 0) exit -1 if !(-f env_mach.${MACH}) then echo "ERROR: machine environment file env_mach.${MACH} does not exist" echo " must first invoke the command " echo " configure -addmach $MACH" endif breaksw default: echo "ERROR: unknown input, invoke configure with no arguments for usage" exit -1 breaksw endsw shift argv end #------------------------------------------------------------- # Note the following is only done for configure -mach option #------------------------------------------------------------- # Determine environment variables source env_conf || "problem sourcing env_conf" && exit -1 source env_run || "problem sourcing env_run" && exit -1 source env_mach.$MACH || "problem sourcing env_mach.$MACH" && exit -1 source env_pes.$MACH || "problem sourcing env_pes.$MACH" && exit -1 source $CASETOOLS/env_setcomp || "problem sourcing env_setcomp" && exit -1 # Error check - run type set value = (startup branch hybrid) set valid = error foreach i ($value) if ($RUN_TYPE == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf RUN_TYPE setting of $RUN_TYPE is not supported" exit -1 endif # Error check - continue run set value = (TRUE FALSE) set valid = error foreach i ($value) if ($CONTINUE_RUN == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_run CONTINUE_RUN setting of $CONTINUE_RUN is not supported" exit -1 endif # Error check - IPCC mode set value = (OFF 1870_CONTROL RAMP_CO2_ONLY) set value = ($value 1870_TO_PRESENT FUTURE_A1 FUTURE_A2 FUTURE_B1 FUTURE_B2) set valid = error foreach i ($value) if ($IPCC_MODE == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf IPCC_MODE setting of $IPCC_MODE is not supported" exit -1 endif # Error check - grid resolution $CCSMROOT/scripts/ccsm_utils/Tools/check_res $GRID if ($status != 0) then echo "ERROR: env_conf GRID setting of $GRID is not supported" exit -1 endif # Error check - comp_atm set value = (cam latm datm xatm) set valid = error foreach i ($value) if ($COMP_ATM == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf COMP_ATM setting of $COMP_ATM is not supported" exit -1 endif # Error check - comp_lnd set value = (clm dlnd xlnd) set valid = error foreach i ($value) if ($COMP_LND == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf COMP_LND setting of $COMP_LND is not supported" exit -1 endif # Error check - comp_ice set value = (csim dice xice) set valid = error foreach i ($value) if ($COMP_ICE == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf COMP_ICE setting of $COMP_ICE is not supported" exit -1 endif # Error check - comp_ocn set value = (pop docn xocn) set valid = error foreach i ($value) if ($COMP_OCN == $i) set valid = ok end if ($valid == error) then echo "ERROR: env_conf COMP_OCN setting of $COMP_OCN is not supported" exit -1 endif # Create resolved build and namelist/presage scripts if ((-d Buildnml_Prestage) && (-d Buildexe) && (-d Buildlib)) then set resolved = true endif if !($?resolved) then $UTILROOT/Tools/generate_resolved.csh || set quit = true if ($?quit) then echo "ERROR: configure generated error in attempting to created resolved scripts" rm -rf Buildnml_Prestage Buildexe Buildlib exit -1 endif endif # Create build, run and long term archiving scripts for specified machine if (-e $CASE.$MACH.run) then cat << EOF ERROR: configuration for $MACH has already been done, invoke the following: configure -cleanmach $MACH configure -mach $MACH EOF exit 1 endif $UTILROOT/Tools/generate_batch.csh || echo "ERROR: configure generate_batch error" && exit -1 # Make a copy of env_conf and env_pes to be able to check that it never # gets changed once configure is invoked if (! -e .cache/env_conf.cache) then cp env_conf .cache/env_conf.cache endif if (! -e .cache/env_pes.$MACH.cache) then cp env_pes.$MACH .cache/env_pes.$MACH.cache endif if ($CCSM_BGC != 'none') then if ( -f $CASEROOT/SourceMods/src.share/cpl_fields_mod.F90 ) then diff $SHAREROOT/cpl/cpl_fields_mod.F90.$CCSM_BGC $CASEROOT/SourceMods/src.share/cpl_fields_mod.F90 if ($status) echo "modified cpl_fields_mod.F90 being used" else cp $SHAREROOT/cpl/cpl_fields_mod.F90.$CCSM_BGC $CASEROOT/SourceMods/src.share/cpl_fields_mod.F90 endif endif #v echo "*************************************************************************" echo "Successfully configured the case for $MACH" #v echo "*************************************************************************"