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