source: palm/trunk/SCRIPTS/palm_simple_run @ 3155

Last change on this file since 3155 was 2875, checked in by knoop, 7 years ago

added file update and unique run dirs to simple installation method

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