#! /bin/csh # # User set shell variables for tgcm24 Linux job: # Data files (solgar, zatmos, magdat) for tgcm24 are copied # from $TGCMDATA into $execdir (see "Copy data" below) # set modeldir = tgcm24 set execdir = tgcm24-linux #set input = tgcm24.inp set output = tgcm24.out set make = Make.generic_hao64 set mpi = TRUE set nproc = 4 set modelres = 5.0 set debug = FALSE set exec = TRUE set utildir = $modeldir/scripts # #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Shell Script for tgcm24 Linux job #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # set mycwd = `pwd` echo "" ; echo "${0}:" echo " Begin execution at `date`" echo " Current working directory: $mycwd" echo " System: `uname -a`" echo "" # # Verify directories and make_machine file (make execdir if necessary). # Get absolute path for dirs that are accessed from the execdir. # if (! -d $modeldir) then echo ">>> Cannot find model directory $modeldir <<<" exit 1 endif set model = $modeldir:t if (! -d $utildir) then echo ">>> Cannot find model scripts directory $utildir <<<" exit 1 endif set srcdir = $modeldir/src if (! -d $srcdir) then echo ">>> Cannot find model source directory $srcdir <<<" exit 1 endif set srcdir = `perl $utildir/abspath $srcdir` if (! -d $execdir) then echo "Making exec directory $execdir" mkdir -p $execdir endif if (! -f $make) set make = $utildir/$make if (! -f $make) then echo ">>> Cannot find make_machine file $make <<<" exit 1 endif set make = `perl $utildir/abspath $make` if ($modelres != 5.0 && $modelres != 2.5) then echo ">>> Unknown model resolution $modelres <<<" exit 1 endif # # Copy make files to execdir if necessary: # if (! -f $execdir/$make) cp $make $execdir if (! -f $execdir/Makefile) cp $utildir/Makefile $execdir if (! -f $execdir/mkdepends) cp $utildir/mkdepends $execdir # # Make default namelist input file if not provided by user: # if ($?input) then if (! -f $input) then echo ">>> Cannot find namelist input file $input <<<" exit 1 endif else set input = \ `perl $utildir/mknamelist -model=$model -modelres=$modelres` || \ echo ">>> Error from mknamelist: fileout = $input" && exit 1 endif set input = `perl $utildir/abspath $input` set output = `perl $utildir/abspath $output` # # Copy defs header file to execdir, if necessary, according to # requested resolution: # if (! -f $execdir/defs.h) then if ($modelres == 5.0) then cp $srcdir/defs.5.0 $execdir/defs.h else cp $srcdir/defs.2.5 $execdir/defs.h endif endif # # Report to stdout: # set svnrevision = `svnversion $modeldir` || set svnrevision = "[none]" echo -n " Model directory: $modeldir" && echo " (SVN revision $svnrevision)" echo " Exec directory: $execdir" echo " Source directory: $srcdir" echo " Make machine file: $make" echo " Namelist input: $input" # # cd to execdir and run make: # cd $execdir || echo ">>> Cannot cd to execdir $execdir" && exit 1 echo "" echo "Begin building $execdir in `pwd`" # # Build Make.env file in exec dir, containing needed env vars for Makefile: # cat << EOF >! Make.env MAKE_MACHINE = $make DIRS = . $srcdir MPI = $mpi NPROC = $nproc EXECNAME = $model NAMELIST = $input OUTPUT = $output DEBUG = $debug EOF # # Build the model: # gmake -j4 all || echo ">>> Error return from gmake all" && exit 1 # # Copy data files for tgcm24 from $TGCMDATA: # (we are currently in $execdir, and the source code is expecting # the $file names) # set file = TGCM.data.magdat.nc # tgcm24 source code is expecting this name if (! -f $file) cp $TGCMDATA/magdat.nc $file \ || echo ">>> Error copying $TGCMDATA/magdat.nc" set file = TGCM.data.solgar_bndry.nc if (! -f $file) cp $TGCMDATA/solgar_bndry.nc $file \ || echo ">>> Error copying $TGCMDATA/solgar_bndry.nc" set file = TGCM.data.solgar_import.nc if (! -f $file) cp $TGCMDATA/solgar_import.nc $file \ || echo ">>> Error copying $TGCMDATA/solgar_import.nc" set file = TGCM.data.zatmos_bndry.nc if (! -f $file) cp $TGCMDATA/zatmos_bndry.nc $file \ || echo ">>> Error copying $TGCMDATA/zatmos_bndry.nc" # # Execute Linux job (MPI or non-MPI run): # (machines.ini rule is in Make.generic_hao64) # if ($exec == "TRUE") then echo "Linux job: Executing $model mpi=$mpi nproc=$nproc" echo "Model output will go to $output" if ($mpi == "TRUE") then gmake machines.ini echo "Executing mpirun -np $nproc for Linux MPI run." mpirun -np $nproc -machinefile machines.ini $model < $input >&! $output || \ echo ">>> ${0} mpirun execution of $model FAILED at `date`" && \ echo "See output in $output" echo "Linux MPI run of $model completed at `date`" else # MPI is FALSE echo "Executing $model for Linux non-MPI run." $model < $input >&! $output || \ echo ">>> ${0} Execution of $model FAILED at `date`" && \ echo "See output in $output" echo "Linux non-MPI run of $model completed at `date`" endif else echo "I am NOT executing $model (exec was not set)" endif exit 0