1 | #!/bin/ksh |
---|
2 | # palm_simple_run - a simple method for running the palm code without |
---|
3 | # using the mrun script |
---|
4 | # $Id: palm_simple_run 755 2011-08-29 09:55:16Z suehring $ |
---|
5 | |
---|
6 | # This script runs the palm code in a unique subdirectory (OUTPUT..., |
---|
7 | # current time/date and number of processors are part of the subdirectory |
---|
8 | # name). |
---|
9 | # It requires that palm has been installed with command |
---|
10 | # palm_simple_install and that the executable palm has been created |
---|
11 | # with make in directory ...../MAKE_DEPOSITORY_simple |
---|
12 | |
---|
13 | # Last changes: |
---|
14 | # 25/01/10 - Siggi - Generating the first version |
---|
15 | # 18/03/10 - Siggi - Some comments changed |
---|
16 | # 29/08/11 - BjornW - Adapted for lcflow (ForWind cluster in Oldenburg) |
---|
17 | |
---|
18 | |
---|
19 | # Variable declarations + default values |
---|
20 | case=example_cbl |
---|
21 | cpumax=999999 |
---|
22 | localhost=unknown |
---|
23 | localhost_realname=$(hostname) |
---|
24 | mpi_procs=1 |
---|
25 | mpi_procs_per_node=1 |
---|
26 | openmp_threads=1 |
---|
27 | |
---|
28 | typeset -i ii |
---|
29 | |
---|
30 | |
---|
31 | # Read shellscript options |
---|
32 | while getopts :c:l:n:p:t: option |
---|
33 | do |
---|
34 | case $option in |
---|
35 | (c) case=$OPTARG;; |
---|
36 | (l) localhost=$OPTARG;; |
---|
37 | (n) mpi_procs_per_node=$OPTARG;; |
---|
38 | (p) mpi_procs=$OPTARG;; |
---|
39 | (t) openmp_threads=$OPTARG;; |
---|
40 | (\?) printf "\n +++ unknown option $OPTARG \n" |
---|
41 | printf "\n allowed option are -d, -f, -l, -s \n" |
---|
42 | exit;; |
---|
43 | esac |
---|
44 | done |
---|
45 | |
---|
46 | |
---|
47 | # Find out the global svn revision number |
---|
48 | global_revision=`svnversion ${palm_dir}trunk 2>/dev/null` |
---|
49 | global_revision="Rev: $global_revision" |
---|
50 | |
---|
51 | |
---|
52 | # Generate unique directory/files for this run |
---|
53 | timedate="`date +%d.%b_%H:%M:%S`" |
---|
54 | suffix=$case+$mpi_procs+$timedate |
---|
55 | RUNDIR=OUTPUT.$suffix/ |
---|
56 | |
---|
57 | if [[ ! -d $RUNDIR ]] |
---|
58 | then |
---|
59 | mkdir $RUNDIR |
---|
60 | echo "*** running in directory $RUNDIR" |
---|
61 | else |
---|
62 | echo "+++ ERROR: $RUNDIR exists\! Must be unique. Exiting." |
---|
63 | exit |
---|
64 | fi |
---|
65 | |
---|
66 | |
---|
67 | # Check if palm has been installed and copy executable into the run |
---|
68 | # directory |
---|
69 | if [[ ! -f ${palm_dir}MAKE_DEPOSITORY_simple/palm ]] |
---|
70 | then |
---|
71 | echo "+++ ERROR: palm executable does not exist." |
---|
72 | echo " Please run \"palm_simple_install\"." |
---|
73 | exit |
---|
74 | else |
---|
75 | cp ${palm_dir}MAKE_DEPOSITORY_simple/palm $RUNDIR/palm |
---|
76 | fi |
---|
77 | |
---|
78 | |
---|
79 | # Check, if parameter file exists and copy into the run directory |
---|
80 | if [[ ! -f ${palm_dir}JOBS/${case}/INPUT/${case}_p3d ]] |
---|
81 | then |
---|
82 | echo "+++ ERROR: parameter file" |
---|
83 | echo " \"${palm_dir}JOBS/${case}/INPUT/${case}_p3d\"" |
---|
84 | echo " does not exist." |
---|
85 | exit |
---|
86 | else |
---|
87 | cp ${palm_dir}JOBS/${case}/INPUT/${case}_p3d $RUNDIR/PARIN |
---|
88 | fi |
---|
89 | |
---|
90 | |
---|
91 | # Switch to run directory |
---|
92 | cd $RUNDIR |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | # Create NAMELIST file containing environment values needed by palm |
---|
97 | cat > ENVPAR << %%END%% |
---|
98 | &envpar run_identifier = '$case', host = '$localhost', |
---|
99 | write_binary = false, tasks_per_node = $mpi_procs_per_node, |
---|
100 | maximum_cpu_time_allowed = ${cpumax}., |
---|
101 | revision = '$global_revision', |
---|
102 | local_dvrserver_running = .FALSE. / |
---|
103 | |
---|
104 | %%END%% |
---|
105 | |
---|
106 | |
---|
107 | # Coupled runs cannot be carried out with this simple run script |
---|
108 | echo "no_coupling" > runfile_atmos |
---|
109 | |
---|
110 | |
---|
111 | # Generate hostfile (if neccessary) |
---|
112 | (( ii = 1 )) |
---|
113 | while (( ii <= $mpi_procs )) |
---|
114 | do |
---|
115 | echo $localhost_realname >> hostfile |
---|
116 | (( ii = ii + 1 )) |
---|
117 | done |
---|
118 | |
---|
119 | |
---|
120 | # Set number of OpenMP threads |
---|
121 | export OMP_NUM_THREADS=$openmp_threads |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | # Start palm run |
---|
126 | echo "*** palm will be run: MPI tasks: $mpi_procs OpenMP thread: $OMP_NUM_THREADS" |
---|
127 | |
---|
128 | # IMUK: |
---|
129 | mpiexec -machinefile hostfile -n $mpi_procs ./palm < runfile_atmos |
---|
130 | |
---|
131 | # SGI-MPT HLRN: |
---|
132 | # mpiexec_mpt -np $mpi_procs ./palm < runfile_atmos |
---|
133 | |
---|
134 | # HPC-FLOW (ForWind): |
---|
135 | # mpiexec -machinefile $TMPDIR/machines -n $mpi_procs -env I_MPI_FABRICS shm:ofa ./palm < runfile_atmos |
---|
136 | |
---|
137 | |
---|
138 | echo "*** palm finished" |
---|
139 | echo "*** see" |
---|
140 | echo " \"$RUNDIR\"" |
---|
141 | echo " for results" |
---|