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