#!/bin/csh -f set rename = false #================================================================================ # 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 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 set valid = `$UTILROOT/Tools/check_machine ${MACH}` if ($status != 0) then echo $valid $UTILROOT/Tools/check_machine -list exit -1 endif 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 setenv COMPORDER "\$COMP_CPL \$COMP_ICE \$COMP_LND \$COMP_OCN \$COMP_ATM" EOF echo "Successfully added $MACH" exit 0 breaksw case "-mach*" if ("$argv[1]" == "-mach4test") then set rename = true endif shift argv source ./env_run || exit -1 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} 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 || echo "problem sourcing env_conf" && exit -1 source env_run || echo "problem sourcing env_run" && exit -1 source env_mach.$MACH || echo "problem sourcing env_mach.$MACH" && exit -1 source env_pes.$MACH || echo "problem sourcing env_pes.$MACH" && exit -1 source $CASETOOLS/env_setcomp || echo "problem sourcing env_setcomp" && exit -1 # 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 $UTILROOT/Tools/ccsm_listcache > .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 if ("$rename" == "true") then mv $CASE.$MACH.run $CASE.run || exit -1 mv $CASE.$MACH.build $CASE.build || exit -1 sed 's#\${CASE}.\${MACH}.build#\$CASE.build#g;'\ $CASE.run > $CASE.run.tmp; mv $CASE.run.tmp $CASE.run if (-f $CASE.$MACH.l_archive) then mv $CASE.$MACH.l_archive $CASE.l_archive || exit -1 endif chmod 755 $CASE.run endif #v echo "*************************************************************************" echo "Successfully configured the case for $MACH" #v echo "*************************************************************************"