source: palm/trunk/SCRIPTS/palm_simple_run @ 2670

Last change on this file since 2670 was 2226, checked in by raasch, 8 years ago

öast commit documented

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