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