[421] | 1 | #!/bin/ksh |
---|
[1046] | 2 | #--------------------------------------------------------------------------------# |
---|
| 3 | # This file is part of PALM. |
---|
| 4 | # |
---|
| 5 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | # either version 3 of the License, or (at your option) any later version. |
---|
| 8 | # |
---|
| 9 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | # |
---|
| 13 | # You should have received a copy of the GNU General Public License along with |
---|
| 14 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | # |
---|
| 16 | # Copyright 1997-2012 Leibniz University Hannover |
---|
| 17 | #--------------------------------------------------------------------------------# |
---|
| 18 | # |
---|
| 19 | # Current revisions: |
---|
| 20 | # ----------------- |
---|
[1171] | 21 | # new option -e which defines the execution command to be used to run PALM |
---|
[1046] | 22 | # |
---|
| 23 | # Former revisions: |
---|
| 24 | # ----------------- |
---|
| 25 | # $Id: palm_simple_run 1171 2013-05-30 11:27:45Z raasch $ |
---|
[1047] | 26 | # |
---|
| 27 | # 1046 2012-11-09 14:38:45Z maronga |
---|
| 28 | # code put under GPL (PALM 3.9) |
---|
[1171] | 29 | # |
---|
| 30 | # 29/08/11 - BjornW - Adapted for lcflow (ForWind cluster in Oldenburg) |
---|
| 31 | # 18/03/10 - Siggi - Some comments changed |
---|
| 32 | # 25/01/10 - Siggi - Generating the first version |
---|
[1046] | 33 | |
---|
[1171] | 34 | |
---|
| 35 | #--------------------------------------------------------------------------------# |
---|
[421] | 36 | # palm_simple_run - a simple method for running the palm code without |
---|
| 37 | # using the mrun script |
---|
[1171] | 38 | # |
---|
| 39 | # This script runs the palm code in a unique subdirectory (OUTPUT..., |
---|
| 40 | # current time/date and number of processors are part of the subdirectory |
---|
| 41 | # name). |
---|
| 42 | # It requires that palm has been installed with command |
---|
| 43 | # palm_simple_install and that the executable palm has been created |
---|
| 44 | # with make in directory ...../MAKE_DEPOSITORY_simple |
---|
| 45 | #--------------------------------------------------------------------------------# |
---|
[421] | 46 | |
---|
| 47 | |
---|
| 48 | # Variable declarations + default values |
---|
| 49 | case=example_cbl |
---|
| 50 | cpumax=999999 |
---|
[1171] | 51 | execute_for=unknown |
---|
[421] | 52 | localhost=unknown |
---|
| 53 | localhost_realname=$(hostname) |
---|
| 54 | mpi_procs=1 |
---|
| 55 | mpi_procs_per_node=1 |
---|
| 56 | openmp_threads=1 |
---|
| 57 | |
---|
| 58 | typeset -i ii |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | # Read shellscript options |
---|
[1171] | 62 | while getopts :c:e:l:n:p:t: option |
---|
[421] | 63 | do |
---|
| 64 | case $option in |
---|
| 65 | (c) case=$OPTARG;; |
---|
[1171] | 66 | (e) execute_for=$OPTARG;; |
---|
[421] | 67 | (l) localhost=$OPTARG;; |
---|
| 68 | (n) mpi_procs_per_node=$OPTARG;; |
---|
| 69 | (p) mpi_procs=$OPTARG;; |
---|
| 70 | (t) openmp_threads=$OPTARG;; |
---|
| 71 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
[1171] | 72 | printf "\n allowed option are -c, -e, -l, -n, -p, -t \n" |
---|
[421] | 73 | exit;; |
---|
| 74 | esac |
---|
| 75 | done |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | # Find out the global svn revision number |
---|
[426] | 79 | global_revision=`svnversion ${palm_dir}trunk 2>/dev/null` |
---|
[421] | 80 | global_revision="Rev: $global_revision" |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | # Generate unique directory/files for this run |
---|
| 84 | timedate="`date +%d.%b_%H:%M:%S`" |
---|
[515] | 85 | suffix=$case+$mpi_procs+$timedate |
---|
[421] | 86 | RUNDIR=OUTPUT.$suffix/ |
---|
| 87 | |
---|
| 88 | if [[ ! -d $RUNDIR ]] |
---|
| 89 | then |
---|
| 90 | mkdir $RUNDIR |
---|
| 91 | echo "*** running in directory $RUNDIR" |
---|
| 92 | else |
---|
| 93 | echo "+++ ERROR: $RUNDIR exists\! Must be unique. Exiting." |
---|
| 94 | exit |
---|
| 95 | fi |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | # Check if palm has been installed and copy executable into the run |
---|
| 99 | # directory |
---|
[426] | 100 | if [[ ! -f ${palm_dir}MAKE_DEPOSITORY_simple/palm ]] |
---|
[421] | 101 | then |
---|
| 102 | echo "+++ ERROR: palm executable does not exist." |
---|
| 103 | echo " Please run \"palm_simple_install\"." |
---|
| 104 | exit |
---|
| 105 | else |
---|
[426] | 106 | cp ${palm_dir}MAKE_DEPOSITORY_simple/palm $RUNDIR/palm |
---|
[421] | 107 | fi |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | # Check, if parameter file exists and copy into the run directory |
---|
[426] | 111 | if [[ ! -f ${palm_dir}JOBS/${case}/INPUT/${case}_p3d ]] |
---|
[421] | 112 | then |
---|
| 113 | echo "+++ ERROR: parameter file" |
---|
[426] | 114 | echo " \"${palm_dir}JOBS/${case}/INPUT/${case}_p3d\"" |
---|
[421] | 115 | echo " does not exist." |
---|
| 116 | exit |
---|
| 117 | else |
---|
[426] | 118 | cp ${palm_dir}JOBS/${case}/INPUT/${case}_p3d $RUNDIR/PARIN |
---|
[421] | 119 | fi |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | # Switch to run directory |
---|
| 123 | cd $RUNDIR |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | # Create NAMELIST file containing environment values needed by palm |
---|
| 128 | cat > ENVPAR << %%END%% |
---|
| 129 | &envpar run_identifier = '$case', host = '$localhost', |
---|
[1171] | 130 | write_binary = 'false', tasks_per_node = $mpi_procs_per_node, |
---|
[421] | 131 | maximum_cpu_time_allowed = ${cpumax}., |
---|
| 132 | revision = '$global_revision', |
---|
| 133 | local_dvrserver_running = .FALSE. / |
---|
| 134 | |
---|
| 135 | %%END%% |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | # Coupled runs cannot be carried out with this simple run script |
---|
| 139 | echo "no_coupling" > runfile_atmos |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | # Generate hostfile (if neccessary) |
---|
| 143 | (( ii = 1 )) |
---|
| 144 | while (( ii <= $mpi_procs )) |
---|
| 145 | do |
---|
| 146 | echo $localhost_realname >> hostfile |
---|
| 147 | (( ii = ii + 1 )) |
---|
| 148 | done |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | # Set number of OpenMP threads |
---|
| 152 | export OMP_NUM_THREADS=$openmp_threads |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | # Start palm run |
---|
| 157 | echo "*** palm will be run: MPI tasks: $mpi_procs OpenMP thread: $OMP_NUM_THREADS" |
---|
| 158 | |
---|
[1171] | 159 | case $execute_for in |
---|
[421] | 160 | |
---|
[1171] | 161 | (imuk) mpiexec -machinefile hostfile -n $mpi_procs ./palm < runfile_atmos;; |
---|
| 162 | (sgi-mpt) mpiexec_mpt -np $mpi_procs ./palm < runfile_atmos;; |
---|
| 163 | (hpc-flow) mpiexec -machinefile $TMPDIR/machines -n $mpi_procs -env I_MPI_FABRICS shm:ofa ./palm < runfile_atmos;; |
---|
| 164 | (pgi-openacc) ./palm;; |
---|
| 165 | (*) echo "+++ -e option to define execution command is missing";; |
---|
[421] | 166 | |
---|
[1171] | 167 | esac |
---|
[515] | 168 | |
---|
[421] | 169 | echo "*** palm finished" |
---|
| 170 | echo "*** see" |
---|
| 171 | echo " \"$RUNDIR\"" |
---|
| 172 | echo " for results" |
---|