1 | #!/bin/ksh |
---|
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 | # ----------------- |
---|
21 | # |
---|
22 | # |
---|
23 | # Former revisions: |
---|
24 | # ----------------- |
---|
25 | # $Id: palm_simple_run 1221 2013-09-10 08:59:13Z raasch $ |
---|
26 | # |
---|
27 | # 1172 2013-05-30 11:46:00Z raasch |
---|
28 | # for performance reasons set PGI_ACC_SYNCHRONOUS=1 for pgi/openacc execution |
---|
29 | # |
---|
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 | # |
---|
33 | # 1046 2012-11-09 14:38:45Z maronga |
---|
34 | # code put under GPL (PALM 3.9) |
---|
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 |
---|
39 | |
---|
40 | |
---|
41 | #--------------------------------------------------------------------------------# |
---|
42 | # palm_simple_run - a simple method for running the palm code without |
---|
43 | # using the mrun script |
---|
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 | #--------------------------------------------------------------------------------# |
---|
52 | |
---|
53 | |
---|
54 | # Variable declarations + default values |
---|
55 | case=example_cbl |
---|
56 | cpumax=999999 |
---|
57 | execute_for=unknown |
---|
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 |
---|
68 | while getopts :c:e:l:n:p:t: option |
---|
69 | do |
---|
70 | case $option in |
---|
71 | (c) case=$OPTARG;; |
---|
72 | (e) execute_for=$OPTARG;; |
---|
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" |
---|
78 | printf "\n allowed option are -c, -e, -l, -n, -p, -t \n" |
---|
79 | exit;; |
---|
80 | esac |
---|
81 | done |
---|
82 | |
---|
83 | |
---|
84 | # Find out the global svn revision number |
---|
85 | global_revision=`svnversion ${palm_dir}trunk 2>/dev/null` |
---|
86 | global_revision="Rev: $global_revision" |
---|
87 | |
---|
88 | |
---|
89 | # Generate unique directory/files for this run |
---|
90 | timedate="`date +%d.%b_%H:%M:%S`" |
---|
91 | suffix=$case+$mpi_procs+$timedate |
---|
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 |
---|
106 | if [[ ! -f ${palm_dir}MAKE_DEPOSITORY_simple/palm ]] |
---|
107 | then |
---|
108 | echo "+++ ERROR: palm executable does not exist." |
---|
109 | echo " Please run \"palm_simple_install\"." |
---|
110 | exit |
---|
111 | else |
---|
112 | cp ${palm_dir}MAKE_DEPOSITORY_simple/palm $RUNDIR/palm |
---|
113 | fi |
---|
114 | |
---|
115 | |
---|
116 | # Check, if parameter file exists and copy into the run directory |
---|
117 | if [[ ! -f ${palm_dir}JOBS/${case}/INPUT/${case}_p3d ]] |
---|
118 | then |
---|
119 | echo "+++ ERROR: parameter file" |
---|
120 | echo " \"${palm_dir}JOBS/${case}/INPUT/${case}_p3d\"" |
---|
121 | echo " does not exist." |
---|
122 | exit |
---|
123 | else |
---|
124 | cp ${palm_dir}JOBS/${case}/INPUT/${case}_p3d $RUNDIR/PARIN |
---|
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', |
---|
136 | write_binary = 'false', tasks_per_node = $mpi_procs_per_node, |
---|
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 | |
---|
165 | case $execute_for in |
---|
166 | |
---|
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;; |
---|
170 | (pgi-openacc) export PGI_ACC_SYNCHRONOUS=1; ./palm;; |
---|
171 | (*) echo "+++ -e option to define execution command is missing";; |
---|
172 | |
---|
173 | esac |
---|
174 | |
---|
175 | echo "*** palm finished" |
---|
176 | echo "*** see" |
---|
177 | echo " \"$RUNDIR\"" |
---|
178 | echo " for results" |
---|