[421] | 1 | #!/bin/ksh |
---|
| 2 | # palm_simple_run - a simple method for running the palm code without |
---|
| 3 | # using the mrun script |
---|
| 4 | # $Id: palm_simple_run 426 2010-01-28 10:08:33Z heinze $ |
---|
| 5 | |
---|
| 6 | # This script runs the palm code in a unique subdirectory (OUTPUT..., |
---|
| 7 | # current time/date and number of processors are part of the subdirectory |
---|
| 8 | # name). |
---|
| 9 | # It requires that palm has been installed with command |
---|
| 10 | # palm_simple_install and that the executable palm has been created |
---|
| 11 | # with make in directory ~/palm/current_version/MAKE_DEPOSITORY_simple |
---|
| 12 | |
---|
| 13 | # Last changes: |
---|
| 14 | # 25/01/10 - Siggi - Generating the first version |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | # Variable declarations + default values |
---|
| 18 | case=example_cbl |
---|
| 19 | cpumax=999999 |
---|
| 20 | localhost=unknown |
---|
| 21 | localhost_realname=$(hostname) |
---|
| 22 | mpi_procs=1 |
---|
| 23 | mpi_procs_per_node=1 |
---|
| 24 | openmp_threads=1 |
---|
[426] | 25 | # palm_dir=~/palm/current_version/ |
---|
[421] | 26 | |
---|
| 27 | typeset -i ii |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | # Read shellscript options |
---|
| 31 | while getopts :c:l:n:p:t: option |
---|
| 32 | do |
---|
| 33 | case $option in |
---|
| 34 | (c) case=$OPTARG;; |
---|
| 35 | (l) localhost=$OPTARG;; |
---|
| 36 | (n) mpi_procs_per_node=$OPTARG;; |
---|
| 37 | (p) mpi_procs=$OPTARG;; |
---|
| 38 | (t) openmp_threads=$OPTARG;; |
---|
| 39 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
| 40 | printf "\n allowed option are -d, -f, -l, -s \n" |
---|
| 41 | exit;; |
---|
| 42 | esac |
---|
| 43 | done |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | # Find out the global svn revision number |
---|
[426] | 47 | global_revision=`svnversion ${palm_dir}trunk 2>/dev/null` |
---|
[421] | 48 | global_revision="Rev: $global_revision" |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | # Generate unique directory/files for this run |
---|
| 52 | timedate="`date +%d.%b_%H:%M:%S`" |
---|
| 53 | suffix=$case+$nnodes+$timedate |
---|
| 54 | RUNDIR=OUTPUT.$suffix/ |
---|
| 55 | |
---|
| 56 | if [[ ! -d $RUNDIR ]] |
---|
| 57 | then |
---|
| 58 | mkdir $RUNDIR |
---|
| 59 | echo "*** running in directory $RUNDIR" |
---|
| 60 | else |
---|
| 61 | echo "+++ ERROR: $RUNDIR exists\! Must be unique. Exiting." |
---|
| 62 | exit |
---|
| 63 | fi |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | # Check if palm has been installed and copy executable into the run |
---|
| 67 | # directory |
---|
[426] | 68 | if [[ ! -f ${palm_dir}MAKE_DEPOSITORY_simple/palm ]] |
---|
[421] | 69 | then |
---|
| 70 | echo "+++ ERROR: palm executable does not exist." |
---|
| 71 | echo " Please run \"palm_simple_install\"." |
---|
| 72 | exit |
---|
| 73 | else |
---|
[426] | 74 | cp ${palm_dir}MAKE_DEPOSITORY_simple/palm $RUNDIR/palm |
---|
[421] | 75 | fi |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | # Check, if parameter file exists and copy into the run directory |
---|
[426] | 79 | if [[ ! -f ${palm_dir}JOBS/${case}/INPUT/${case}_p3d ]] |
---|
[421] | 80 | then |
---|
| 81 | echo "+++ ERROR: parameter file" |
---|
[426] | 82 | echo " \"${palm_dir}JOBS/${case}/INPUT/${case}_p3d\"" |
---|
[421] | 83 | echo " does not exist." |
---|
| 84 | exit |
---|
| 85 | else |
---|
[426] | 86 | cp ${palm_dir}JOBS/${case}/INPUT/${case}_p3d $RUNDIR/PARIN |
---|
[421] | 87 | fi |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | # Switch to run directory |
---|
| 91 | cd $RUNDIR |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | # Create NAMELIST file containing environment values needed by palm |
---|
| 96 | cat > ENVPAR << %%END%% |
---|
| 97 | &envpar run_identifier = '$case', host = '$localhost', |
---|
| 98 | write_binary = false, tasks_per_node = $mpi_procs_per_node, |
---|
| 99 | maximum_cpu_time_allowed = ${cpumax}., |
---|
| 100 | revision = '$global_revision', |
---|
| 101 | local_dvrserver_running = .FALSE. / |
---|
| 102 | |
---|
| 103 | %%END%% |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | # Coupled runs cannot be carried out with this simple run script |
---|
| 107 | echo "no_coupling" > runfile_atmos |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | # Generate hostfile (if neccessary) |
---|
| 111 | (( ii = 1 )) |
---|
| 112 | while (( ii <= $mpi_procs )) |
---|
| 113 | do |
---|
| 114 | echo $localhost_realname >> hostfile |
---|
| 115 | (( ii = ii + 1 )) |
---|
| 116 | done |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | # Set number of OpenMP threads |
---|
| 120 | export OMP_NUM_THREADS=$openmp_threads |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | # Start palm run |
---|
| 125 | echo "*** palm will be run: MPI tasks: $mpi_procs OpenMP thread: $OMP_NUM_THREADS" |
---|
| 126 | |
---|
[424] | 127 | # mpiexec -machinefile hostfile -n $mpi_procs ./palm < runfile_atmos |
---|
| 128 | mpiexec_mpt -np $mpi_procs ./palm < runfile_atmos |
---|
[421] | 129 | |
---|
| 130 | |
---|
| 131 | echo "*** palm finished" |
---|
| 132 | echo "*** see" |
---|
| 133 | echo " \"$RUNDIR\"" |
---|
| 134 | echo " for results" |
---|