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