1#!/usr/local/bin/bash 2# 3# Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org) 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18if [ "$1" = "--help" ]; then 19 cat <<EOF 20${0##*/}, version %version% 21This script runs a generic simulation program 22 23Usage: ${0##*/} 24EOF 25 exit 0 26fi 27 28sim_prog="$(csg_get_property cg.inverse.program)" 29script="$(csg_get_property --allow-empty cg.inverse.$sim_prog.script)" 30[[ -n $script && ! -f $script ]] && die "${0##*/}: $sim_prog script '$script' not found (make sure it is in cg.inverse.filelist)" 31 32cmd="$(csg_get_property cg.inverse.$sim_prog.command)" 33#no check for cmd, because cmd could maybe exist only computenodes 34 35opts=$(csg_get_property --allow-empty cg.inverse.$sim_prog.opts) 36#expand ${script} in there 37opts="$(eval echo $opts)" 38 39if [[ -n $CSGENDING ]]; then 40 echo "${0##*/}: $sim_prog does not support wallclock time yet (go here and implement it). Per step wallclock time check is still performed!" 41fi 42 43if [[ ${CSG_MDRUN_STEPS} && ! ${CSG_DONT_OVERWRITE_MDRUN_STEPS} ]]; then 44 if [[ ${sim_prog} = "lammps" ]]; then 45 critical sed -i "/^run/s/[0-9][0-9]*/${CSG_MDRUN_STEPS}/" "$script" 46 msg --color blue --to-stderr "Replace run STEPS in '$script' to be ${CSG_MDRUN_STEPS}" 47 elif [[ ${sim_prog} = "espresso" ]]; then 48 critical sed -i -e "/^steps_per_int/s/[0-9][0-9]*/${CSG_MDRUN_STEPS}/" \ 49 -e '/^\(int\|eq\)_steps/s/[0-9][0-9]*/1/' "$script" 50 msg --color blue --to-stderr "Replace steps_per_int in '$script' to be ${CSG_MDRUN_STEPS} and int_steps to be 1" 51 else 52 msg --color blue --to-stderr "Overwriting of nsteps for ${sim_prog} not supported yet" 53 fi 54fi 55 56method="$(csg_get_property cg.inverse.method)" 57shopt -s extglob 58is_part "$method" "ibi imc optimizer re" || die "${0##*/}: ${sim_prog} does not support method $method yet!" 59 60critical $cmd ${opts} 61 62simulation_finish 63