source: palm/trunk/SCRIPTS/palm_simple_run @ 4260

Last change on this file since 4260 was 3414, checked in by raasch, 6 years ago

bugfix: envpar namelist adjusted to current PALM revision

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.9 KB
RevLine 
[2850]1#!/usr/bin/env bash
[1046]2#--------------------------------------------------------------------------------#
[2696]3# This file is part of the PALM model system.
[1046]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#
[2718]16# Copyright 1997-2018  Leibniz Universitaet Hannover
[1046]17#--------------------------------------------------------------------------------#
18#
19# Current revisions:
20# -----------------
[2226]21#
[2716]22#
[1046]23# Former revisions:
24# -----------------
25# $Id: palm_simple_run 3414 2018-10-24 11:40:57Z hellstea $
[3414]26# bugfix: envpar namelist adjusted to current PALM revision
27#
28# 2875 2018-03-13 11:00:25Z knoop
[2875]29# made RUN dirs unique with timestamp again
30#
31# 2850 2018-03-05 14:24:40Z knoop
[2850]32# Refactoring of the palm_simple_ build and run scripts
33#
34# 2718 2018-01-02 08:49:38Z maronga
[2716]35# Corrected "Former revisions" section
[1047]36#
[2716]37# 2696 2017-12-14 17:12:51Z kanani
38# Change in file header (GPL part)
39#
[2226]40# 2225 2017-05-16 11:36:20Z raasch
41# shell changed to bash
42#
[2716]43# 1310 2014-03-14 08:01:56Z raasch
44# update GPL copyright
45#
[1222]46# 1221 2013-09-10 08:59:13Z raasch
47# setting of PGI_ACC_SYNCHRONOUS=1 for running with pgi-openacc
48#
[1221]49# 1172 2013-05-30 11:46:00Z raasch
50# for performance reasons set PGI_ACC_SYNCHRONOUS=1 for pgi/openacc execution
51#
[1172]52# 1171 2013-05-30 11:27:45Z raasch
53# new option -e which defines the execution command to be used to run PALM
54#
[1047]55# 1046 2012-11-09 14:38:45Z maronga
56# code put under GPL (PALM 3.9)
[1171]57#
58# 29/08/11 - BjornW - Adapted for lcflow (ForWind cluster in Oldenburg)
59# 18/03/10 - Siggi  - Some comments changed
60# 25/01/10 - Siggi  - Generating the first version
[1046]61
[1171]62
63#--------------------------------------------------------------------------------#
[421]64# palm_simple_run - a simple method for running the palm code without
65#                   using the mrun script
[1171]66#
67# This script runs the palm code in a unique subdirectory (OUTPUT...,
68# current time/date and number of processors are part of the subdirectory
69# name).
70# It requires that palm has been installed with command
71# palm_simple_install and that the executable palm has been created
72# with make in directory  ...../MAKE_DEPOSITORY_simple
73#--------------------------------------------------------------------------------#
[2850]74SOURCE="${BASH_SOURCE[0]}"
75while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
76  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
77  SOURCE="$(readlink "$SOURCE")"
78  # if $SOURCE was a relative symlink, we need to resolve it
79  # relative to the path where the symlink file was located
80  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
81done
82SCRIPT_LOCATION="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
[421]83
[2850]84working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../")
85trunk_dir=$(readlink -f "${SCRIPT_LOCATION}/../")
[421]86
[2850]87# Variable declarations + default values
88build_config=unknown
89run_config=unknown
90test_case=unknown
91mpi_ranks=1
92mpi_ranks_per_node=1
93openmp_threads=1
94localhost_realname=$(hostname)
95cpumax=999999
[421]96
[2850]97print_help() {
98   echo "Usage: palm_simple_run -b <build-config> -c <run-config> -s <test-case>"
99   echo "                       [-n <mpi-ranks-per-node>] [-p <mpi-ranks>]"
100   echo "                       [-t <openmp-threads>]"
101   echo ""
102   echo "List of allowed option:"
103   echo ""
104   echo "   -b <build-config>        Suffix of any MAKE.inc.<build-config> file in the trunk/INSTALL dir."
105   echo "   -c <run-config>          Suffix of any RUN.cmd.<run-config> file in the trunk/INSTALL dir."
106   echo "   -n <mpi-ranks-per-node>  Number of MPI ranks per compute node."
107   echo "   -p <mpi-ranks>           Number of MPI ranks in total."
108   echo "   -s <test-case>           Prefix of any <test-case>_p3d file in the trunk/INSTALL dir."
109   echo "   -t <openmp-threads>      Number of OpenMP threads"
110   echo ""
111   echo ""
112}
[421]113
114
[2850]115   # Read shellscript options
116while  getopts  :b:c:n:p:s:t:h  option
117do
118  case  $option  in
119      (b)   build_config=$OPTARG;;
120      (c)   run_config=$OPTARG;;
121      (n)   mpi_ranks_per_node=$OPTARG;;
122      (p)   mpi_ranks=$OPTARG;;
123      (s)   test_case=$OPTARG;;
124      (t)   openmp_threads=$OPTARG;;
125      (h)   print_help
126            exit 0;;
127      (\?)  echo "Unknown option -$OPTARG"
128            print_help
129            exit 1;;
130  esac
131done
[421]132
[2850]133if [[ ${build_config} == "unknown" ]]
134then
135   echo "Missing option -b <build-config>"
136   print_help
137   exit 1
138fi
[421]139
[2850]140if [[ ${run_config} == "unknown" ]]
141then
142   echo "Missing option -c <run-config>"
143   print_help
144   exit 1
145fi
[421]146
[2850]147if [[ ${test_case} == "unknown" ]]
148then
149   echo "Missing option -s <test-case>"
150   print_help
151   exit 1
152fi
[421]153
[2850]154build_dir=${working_dir}/BUILD_${build_config}
[421]155
[2850]156if [[ ! -d ${build_dir} ]]
157then
158   echo "+++ ERROR: No build for configuration ${build_config} exists! "
159   echo "           Please run \"palm_simple_install -b ${build_config}\""
160   echo "           or specify a different build that this run should be based on"
161   exit 1
162fi
[421]163
[2850]164   # Check, if include file exists
165run_config_file=${trunk_dir}/INSTALL/RUN.cmd.${run_config}
166if [[ ! -f ${run_config_file} ]]
167then
168   echo "+++ ERROR: no such run command file:"
169   echo "    \"${run_config_file}\""
170   exit 1
171fi
[421]172
[2850]173   # Find out the global svn revision number
174global_revision=$(svnversion ${trunk_dir}  2>/dev/null)
175global_revision="Rev: $global_revision"
[421]176
177
[2850]178   # Generate unique directory/files for this run
[2875]179timedate="$(date +%F_%H:%M:%S)"
180suffix=${build_config}_${run_config}_${test_case}_${mpi_ranks}_${mpi_ranks_per_node}_${openmp_threads}_${timedate}
[2850]181execution_dir=${working_dir}/RUN_${suffix}
[421]182
[2850]183if [[ ! -d ${execution_dir} ]]
184then
185   mkdir -p ${execution_dir}
186   echo "*** PALM running in directory ${execution_dir}"
187else
188   echo "+++ ERROR: ${execution_dir} exists\!   Must be unique.  Exiting."
189   exit 1
190fi
[421]191
192
[2850]193# Check if palm has been installed and copy executable into the run
194# directory
195if [[ ! -f ${build_dir}/palm ]]
196then
197   echo "+++ ERROR: palm executable does not exist."
198   echo "           Please run \"palm_simple_install\"."
199   exit 1
200else
201   cp  ${build_dir}/palm  ${execution_dir}/palm
202fi
[421]203
204
[2850]205# Check, if parameter file exists and copy into the run directory
206if [[ ! -f ${trunk_dir}/INSTALL/${test_case}_p3d ]]
207then
208   echo "+++ ERROR: parameter file"
209   echo "           \"${trunk_dir}/INSTALL/${test_case}_p3d\""
210   echo "           does not exist."
211   exit 1
212else
213   cp  ${trunk_dir}/INSTALL/${test_case}_p3d  ${execution_dir}/PARIN
214fi
[421]215
216
217
218
[2850]219# Create NAMELIST file containing environment values needed by palm
220cat  >  ${execution_dir}/ENVPAR  <<  EOF
221&envpar  run_identifier = '${test_case}',
222         host = 'localhost',
223         revision = '${global_revision}',
224         tasks_per_node = ${mpi_ranks_per_node},
225         maximum_parallel_io_streams = ${mpi_ranks_per_node},
[3414]226         progress_bar_disabled = .TRUE.,
[2850]227         write_binary = .FALSE.,
228         maximum_cpu_time_allowed = ${cpumax}.,
229         local_dvrserver_running = .FALSE.,
230/
231EOF
[421]232
233
[2850]234# Coupled runs cannot be carried out with this simple run script
235echo "no_coupling"  >  ${execution_dir}/runfile_atmos
[421]236
237
[2850]238# Generate hostfile (if neccessary)
239(( ii = 1 ))
240while (( ii <= $mpi_ranks ))
241do
242   echo  $localhost_realname  >>  ${execution_dir}/hostfile
243   (( ii = ii + 1 ))
244done
[421]245
246
[2850]247# Switch to run directory
248cd  ${execution_dir}
[421]249
[2850]250# Start palm run
251echo "*** PALM will be executed with configuration: ${run_config}"
252echo "       MPI ranks in total: $mpi_ranks"
253echo "       MPI ranks per node: $mpi_ranks_per_node"
254echo "       OpenMP threads:     $openmp_threads"
[421]255
[2850]256# execute according to the run command file
257source ${run_config_file}
[421]258
[2850]259echo "*** PALM execution finished. Results can be found in:"
260echo "    \"${execution_dir}\""
261exit 0
Note: See TracBrowser for help on using the repository browser.