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