Changeset 2850 for palm/trunk/SCRIPTS
- Timestamp:
- Mar 5, 2018 2:24:40 PM (7 years ago)
- Location:
- palm/trunk/SCRIPTS
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/palm_simple_build
r2849 r2850 1 #!/ bin/bash1 #!/usr/bin/env bash 2 2 #--------------------------------------------------------------------------------# 3 3 # This file is part of the PALM model system. … … 24 24 # ----------------- 25 25 # $Id$ 26 # Refactoring of the palm_simple_ build and run scripts 27 # 28 # 2718 2018-01-02 08:49:38Z maronga 26 29 # Corrected "Former revisions" section 27 30 # … … 40 43 # palm_simple_install - a script for simple installation and compilation of 41 44 # the palm code without using mbuild 42 43 44 45 45 # This script creates (from the working copy of the palm repository) 46 # a subdirectory MAKE_DEPOSITORY_simple which contains a copy of the 47 # palm source code and a modified makefile which loads required compiler 48 # and preprocessor settings via "include MAKE.inc" 46 49 47 48 50 # Options: -i <include file> 51 # one of the include files in ~/palm/current_version/trunk/INSTALL 49 52 50 # Last changes: 51 # 25/01/10 - Siggi - Generating the first version 52 # 18/03/10 - Siggi - switch to palm/current_version removed: working 53 # copy can be in any directory 53 # Last changes: 54 # 25/01/10 - Siggi - Generating the first version 55 # 18/03/10 - Siggi - switch to palm/current_version removed: working 56 # copy can be in any directory 57 #------------------------------------------------------------------------------# 58 SOURCE="${BASH_SOURCE[0]}" 59 while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 60 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 61 SOURCE="$(readlink "$SOURCE")" 62 # if $SOURCE was a relative symlink, we need to resolve it 63 # relative to the path where the symlink file was located 64 [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 65 done 66 SCRIPT_LOCATION="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 67 68 working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../") 69 trunk_dir=$(readlink -f "${SCRIPT_LOCATION}/../") 54 70 55 71 56 # Variable declarations + default values 57 include_file=unknown 72 get_number_of_cpu_cores() { 73 { 74 n=$(sysctl -n machdep.cpu.core_count 2> /dev/null) 75 } || { 76 n=$(grep -c ^processor /proc/cpuinfo 2> /dev/null) 77 } || { 78 if ! [[ $n =~ ^-?[0-9]+$ ]]; then 79 n=1 80 fi 81 } 82 echo $n 83 } 84 85 print_help() { 86 echo "Usage: palm_simple_run -b <build-config> [-x]" 87 echo "" 88 echo "List of allowed option:" 89 echo "" 90 echo " -b <build-config> Suffix of any MAKE.inc.<build-config> file in the trunk/INSTALL dir." 91 echo " -x Clean the build directory from last build attempts" 92 echo "" 93 } 94 95 build_config=unknown 96 clean="false" 97 98 # Read shellscript options 99 while getopts :b:xh option 100 do 101 case $option in 102 (b) build_config=$OPTARG;; 103 (x) clean="true";; 104 (h) print_help 105 exit 0;; 106 (\?) echo "Unknown option -$OPTARG" 107 print_help 108 exit 1;; 109 esac 110 done 111 112 if [[ ${build_config} == "unknown" ]]; then 113 echo "Missing option -b <build-config>" 114 print_help 115 exit 1 116 fi 58 117 59 118 60 # Read shellscript options 61 while getopts :i: option 62 do 63 case $option in 64 (i) include_file=$OPTARG;; 65 (\?) printf "\n +++ unknown option $OPTARG \n" 66 printf "\n allowed option are -d, -f, -l, -s \n" 67 exit;; 68 esac 69 done 119 build_dir=${working_dir}/MAKE_DEPOSITORY_$build_config 70 120 71 121 72 73 # Check, if include file exists 74 if [[ ! -f trunk/INSTALL/$include_file ]] 75 then 76 echo "+++ ERROR: include file" 77 echo " \"trunk/INSTALL/$include_file\"" 78 echo " not found" 79 exit 80 fi 122 # Check, if include file exists 123 build_config_file=${trunk_dir}/INSTALL/MAKE.inc.$build_config 124 if [[ ! -f ${build_config_file} ]]; then 125 echo "+++ ERROR: no such make include file:" 126 echo " \"${build_config_file}\"" 127 exit 1 128 fi 81 129 82 130 83 # Create the make depository 84 if [[ ! -d MAKE_DEPOSITORY_simple ]] 85 then 86 mkdir MAKE_DEPOSITORY_simple 87 else 88 rm MAKE_DEPOSITORY_simple/* 89 fi 131 # Create the make depository 132 if [[ ! -d ${build_dir} ]]; then 133 mkdir -p ${build_dir} 134 else 135 if [[ ${clean} == "true" ]]; then 136 echo "Cleaning the build directory..." 137 rm -rf ${build_dir}/* 138 fi 139 fi 90 140 91 141 92 93 cp trunk/SOURCE/Makefile MAKE_DEPOSITORY_simple/Makefile_old 94 cp trunk/INSTALL/$include_file MAKE_DEPOSITORY_simple/MAKE.inc95 cp trunk/SOURCE/*.f90 MAKE_DEPOSITORY_simple 142 # Copy makefile and all source code files to make depository 143 cp -n ${trunk_dir}/SOURCE/Makefile ${build_dir}/Makefile_in 144 cp -n ${build_config_file} ${build_dir}/MAKE.inc 145 cp -n ${trunk_dir}/SOURCE/*.f90 ${build_dir} 96 146 97 147 98 # Replace comment in makefile by include statement 99 sed 's/#to_be_replaced_by_include/include MAKE.inc/g' MAKE_DEPOSITORY_simple/Makefile_old > MAKE_DEPOSITORY_simple/Makefile 100 rm MAKE_DEPOSITORY_simple/Makefile_old 148 # Replace comment in makefile by include statement 149 sed 's/#to_be_replaced_by_include/include MAKE.inc/g' ${build_dir}/Makefile_in > ${build_dir}/Makefile 150 rm ${build_dir}/Makefile_in 151 152 cd ${build_dir} 153 make -j $(get_number_of_cpu_cores) 154 cd ../ 101 155 102 156 103 # Create directory for input files 104 if [[ ! -d JOBS/example_cbl/INPUT ]] 105 then 106 mkdir -p JOBS/example_cbl/INPUT 107 cp trunk/INSTALL/example_cbl_p3d JOBS/example_cbl/INPUT 108 fi 157 echo "*** PALM build finished. Executable can be found in:" 158 echo " \"${build_dir}\"" 159 exit 0 -
palm/trunk/SCRIPTS/palm_simple_run
r2718 r2850 1 #!/ bin/bash1 #!/usr/bin/env bash 2 2 #--------------------------------------------------------------------------------# 3 3 # This file is part of the PALM model system. … … 24 24 # ----------------- 25 25 # $Id$ 26 # Refactoring of the palm_simple_ build and run scripts 27 # 28 # 2718 2018-01-02 08:49:38Z maronga 26 29 # Corrected "Former revisions" section 27 30 # … … 63 66 # with make in directory ...../MAKE_DEPOSITORY_simple 64 67 #--------------------------------------------------------------------------------# 65 66 67 # Variable declarations + default values 68 case=example_cbl 69 cpumax=999999 70 execute_for=unknown 71 localhost=unknown 72 localhost_realname=$(hostname) 73 mpi_procs=1 74 mpi_procs_per_node=1 75 openmp_threads=1 76 77 typeset -i ii 78 79 80 # Read shellscript options 81 while getopts :c:e:l:n:p:t: option 82 do 83 case $option in 84 (c) case=$OPTARG;; 85 (e) execute_for=$OPTARG;; 86 (l) localhost=$OPTARG;; 87 (n) mpi_procs_per_node=$OPTARG;; 88 (p) mpi_procs=$OPTARG;; 89 (t) openmp_threads=$OPTARG;; 90 (\?) printf "\n +++ unknown option $OPTARG \n" 91 printf "\n allowed option are -c, -e, -l, -n, -p, -t \n" 92 exit;; 93 esac 94 done 95 96 97 # Find out the global svn revision number 98 global_revision=`svnversion ${palm_dir}trunk 2>/dev/null` 99 global_revision="Rev: $global_revision" 100 101 102 # Generate unique directory/files for this run 103 timedate="`date +%d.%b_%H:%M:%S`" 104 suffix=$case+$mpi_procs+$timedate 105 RUNDIR=OUTPUT.$suffix/ 106 107 if [[ ! -d $RUNDIR ]] 108 then 109 mkdir $RUNDIR 110 echo "*** running in directory $RUNDIR" 111 else 112 echo "+++ ERROR: $RUNDIR exists\! Must be unique. Exiting." 113 exit 114 fi 115 116 117 # Check if palm has been installed and copy executable into the run 118 # directory 119 if [[ ! -f ${palm_dir}MAKE_DEPOSITORY_simple/palm ]] 120 then 121 echo "+++ ERROR: palm executable does not exist." 122 echo " Please run \"palm_simple_install\"." 123 exit 124 else 125 cp ${palm_dir}MAKE_DEPOSITORY_simple/palm $RUNDIR/palm 126 fi 127 128 129 # Check, if parameter file exists and copy into the run directory 130 if [[ ! -f ${palm_dir}JOBS/${case}/INPUT/${case}_p3d ]] 131 then 132 echo "+++ ERROR: parameter file" 133 echo " \"${palm_dir}JOBS/${case}/INPUT/${case}_p3d\"" 134 echo " does not exist." 135 exit 136 else 137 cp ${palm_dir}JOBS/${case}/INPUT/${case}_p3d $RUNDIR/PARIN 138 fi 139 140 141 # Switch to run directory 142 cd $RUNDIR 143 144 145 146 # Create NAMELIST file containing environment values needed by palm 147 cat > ENVPAR << %%END%% 148 &envpar run_identifier = '$case', host = '$localhost', 149 write_binary = 'false', tasks_per_node = $mpi_procs_per_node, 150 maximum_cpu_time_allowed = ${cpumax}., 151 revision = '$global_revision', 152 local_dvrserver_running = .FALSE. / 153 154 %%END%% 155 156 157 # Coupled runs cannot be carried out with this simple run script 158 echo "no_coupling" > runfile_atmos 159 160 161 # Generate hostfile (if neccessary) 162 (( ii = 1 )) 163 while (( ii <= $mpi_procs )) 164 do 165 echo $localhost_realname >> hostfile 166 (( ii = ii + 1 )) 167 done 168 169 170 # Set number of OpenMP threads 171 export OMP_NUM_THREADS=$openmp_threads 172 173 174 175 # Start palm run 176 echo "*** palm will be run: MPI tasks: $mpi_procs OpenMP thread: $OMP_NUM_THREADS" 177 178 case $execute_for in 179 180 (imuk) mpiexec -machinefile hostfile -n $mpi_procs ./palm < runfile_atmos;; 181 (sgi-mpt) mpiexec_mpt -np $mpi_procs ./palm < runfile_atmos;; 182 (hpc-flow) mpiexec -machinefile $TMPDIR/machines -n $mpi_procs -env I_MPI_FABRICS shm:ofa ./palm < runfile_atmos;; 183 (pgi-openacc) export PGI_ACC_SYNCHRONOUS=1; ./palm;; 184 (*) echo "+++ -e option to define execution command is missing";; 185 186 esac 187 188 echo "*** palm finished" 189 echo "*** see" 190 echo " \"$RUNDIR\"" 191 echo " for results" 68 SOURCE="${BASH_SOURCE[0]}" 69 while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink 70 DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 71 SOURCE="$(readlink "$SOURCE")" 72 # if $SOURCE was a relative symlink, we need to resolve it 73 # relative to the path where the symlink file was located 74 [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 75 done 76 SCRIPT_LOCATION="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 77 78 working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../") 79 trunk_dir=$(readlink -f "${SCRIPT_LOCATION}/../") 80 81 # Variable declarations + default values 82 build_config=unknown 83 run_config=unknown 84 test_case=unknown 85 mpi_ranks=1 86 mpi_ranks_per_node=1 87 openmp_threads=1 88 localhost_realname=$(hostname) 89 cpumax=999999 90 91 print_help() { 92 echo "Usage: palm_simple_run -b <build-config> -c <run-config> -s <test-case>" 93 echo " [-n <mpi-ranks-per-node>] [-p <mpi-ranks>]" 94 echo " [-t <openmp-threads>]" 95 echo "" 96 echo "List of allowed option:" 97 echo "" 98 echo " -b <build-config> Suffix of any MAKE.inc.<build-config> file in the trunk/INSTALL dir." 99 echo " -c <run-config> Suffix of any RUN.cmd.<run-config> file in the trunk/INSTALL dir." 100 echo " -n <mpi-ranks-per-node> Number of MPI ranks per compute node." 101 echo " -p <mpi-ranks> Number of MPI ranks in total." 102 echo " -s <test-case> Prefix of any <test-case>_p3d file in the trunk/INSTALL dir." 103 echo " -t <openmp-threads> Number of OpenMP threads" 104 echo "" 105 echo "" 106 } 107 108 109 # Read shellscript options 110 while getopts :b:c:n:p:s:t:h option 111 do 112 case $option in 113 (b) build_config=$OPTARG;; 114 (c) run_config=$OPTARG;; 115 (n) mpi_ranks_per_node=$OPTARG;; 116 (p) mpi_ranks=$OPTARG;; 117 (s) test_case=$OPTARG;; 118 (t) openmp_threads=$OPTARG;; 119 (h) print_help 120 exit 0;; 121 (\?) echo "Unknown option -$OPTARG" 122 print_help 123 exit 1;; 124 esac 125 done 126 127 if [[ ${build_config} == "unknown" ]] 128 then 129 echo "Missing option -b <build-config>" 130 print_help 131 exit 1 132 fi 133 134 if [[ ${run_config} == "unknown" ]] 135 then 136 echo "Missing option -c <run-config>" 137 print_help 138 exit 1 139 fi 140 141 if [[ ${test_case} == "unknown" ]] 142 then 143 echo "Missing option -s <test-case>" 144 print_help 145 exit 1 146 fi 147 148 build_dir=${working_dir}/BUILD_${build_config} 149 150 if [[ ! -d ${build_dir} ]] 151 then 152 echo "+++ ERROR: No build for configuration ${build_config} exists! " 153 echo " Please run \"palm_simple_install -b ${build_config}\"" 154 echo " or specify a different build that this run should be based on" 155 exit 1 156 fi 157 158 # Check, if include file exists 159 run_config_file=${trunk_dir}/INSTALL/RUN.cmd.${run_config} 160 if [[ ! -f ${run_config_file} ]] 161 then 162 echo "+++ ERROR: no such run command file:" 163 echo " \"${run_config_file}\"" 164 exit 1 165 fi 166 167 # Find out the global svn revision number 168 global_revision=$(svnversion ${trunk_dir} 2>/dev/null) 169 global_revision="Rev: $global_revision" 170 171 172 # Generate unique directory/files for this run 173 #timedate="$(date +%F_%H:%M:%S)" 174 suffix=${build_config}_${run_config}_${test_case}_${mpi_ranks}_${mpi_ranks_per_node}_${openmp_threads} 175 execution_dir=${working_dir}/RUN_${suffix} 176 177 if [[ ! -d ${execution_dir} ]] 178 then 179 mkdir -p ${execution_dir} 180 echo "*** PALM running in directory ${execution_dir}" 181 else 182 echo "+++ ERROR: ${execution_dir} exists\! Must be unique. Exiting." 183 exit 1 184 fi 185 186 187 # Check if palm has been installed and copy executable into the run 188 # directory 189 if [[ ! -f ${build_dir}/palm ]] 190 then 191 echo "+++ ERROR: palm executable does not exist." 192 echo " Please run \"palm_simple_install\"." 193 exit 1 194 else 195 cp ${build_dir}/palm ${execution_dir}/palm 196 fi 197 198 199 # Check, if parameter file exists and copy into the run directory 200 if [[ ! -f ${trunk_dir}/INSTALL/${test_case}_p3d ]] 201 then 202 echo "+++ ERROR: parameter file" 203 echo " \"${trunk_dir}/INSTALL/${test_case}_p3d\"" 204 echo " does not exist." 205 exit 1 206 else 207 cp ${trunk_dir}/INSTALL/${test_case}_p3d ${execution_dir}/PARIN 208 fi 209 210 211 212 213 # Create NAMELIST file containing environment values needed by palm 214 cat > ${execution_dir}/ENVPAR << EOF 215 &envpar run_identifier = '${test_case}', 216 host = 'localhost', 217 revision = '${global_revision}', 218 tasks_per_node = ${mpi_ranks_per_node}, 219 maximum_parallel_io_streams = ${mpi_ranks_per_node}, 220 batch_job = .TRUE., 221 write_binary = .FALSE., 222 maximum_cpu_time_allowed = ${cpumax}., 223 local_dvrserver_running = .FALSE., 224 / 225 EOF 226 227 228 # Coupled runs cannot be carried out with this simple run script 229 echo "no_coupling" > ${execution_dir}/runfile_atmos 230 231 232 # Generate hostfile (if neccessary) 233 (( ii = 1 )) 234 while (( ii <= $mpi_ranks )) 235 do 236 echo $localhost_realname >> ${execution_dir}/hostfile 237 (( ii = ii + 1 )) 238 done 239 240 241 # Switch to run directory 242 cd ${execution_dir} 243 244 # Start palm run 245 echo "*** PALM will be executed with configuration: ${run_config}" 246 echo " MPI ranks in total: $mpi_ranks" 247 echo " MPI ranks per node: $mpi_ranks_per_node" 248 echo " OpenMP threads: $openmp_threads" 249 250 # execute according to the run command file 251 source ${run_config_file} 252 253 echo "*** PALM execution finished. Results can be found in:" 254 echo " \"${execution_dir}\"" 255 exit 0
Note: See TracChangeset
for help on using the changeset viewer.