From dbb3bcb3cec99ed8841ef0058dabaa4aadac8d6f Mon Sep 17 00:00:00 2001 From: cryobry <38270216+cryobry@users.noreply.github.com> Date: Sun, 10 Jun 2018 22:59:27 -0400 Subject: [PATCH] auto_namd initial commit --- auto_namd/functions.sh | 441 +++++++++++++++++++++++++++++++++++++++++ auto_namd/hosts.sh | 128 ++++++++++++ auto_namd/run.sh | 63 ++++++ 3 files changed, 632 insertions(+) create mode 100755 auto_namd/functions.sh create mode 100755 auto_namd/hosts.sh create mode 100755 auto_namd/run.sh diff --git a/auto_namd/functions.sh b/auto_namd/functions.sh new file mode 100755 index 0000000..9694921 --- /dev/null +++ b/auto_namd/functions.sh @@ -0,0 +1,441 @@ +#!/usr/bin/env bash + +function get_next_step() { + + # get system name from path + system=$(basename "${job}") + + # get prev_step and prev_step_num from parsing coor filenames + last_step_coorname=$(find ${job} -name "*.coor" -type f | sort -V | tail -n 1) + if [[ "${last_step_coorname}" == "" ]]; then + prev_step="" + else + filename=$(basename ${last_step_coorname}) + filename=${filename%%.*} + prev_step=${filename##${system}_} + prev_step=${prev_step%%_*} + fi + case "${prev_step}" in + "4-sim") + this_step="4-sim" + prev_step_num=${filename##*[^0-9]} + final_step_num=$((${prev_step_num}+${step_size})) + ;; + "3-heat") + this_step="4-sim" + prev_step_num=0 + final_step_num=${step_size} + ;; + "2-min") + this_step="3-heat" + prev_step_num=0 + final_step_num=0 + ;; + "1-min") + this_step="2-min" + prev_step_num=0 + final_step_num=0 + ;; + "") + if [[ -f "${job}/${system}.pdb" && -f "${job}/${system}.psf" ]]; then + this_step="1-min" + prev_step_num=0 + final_step_num=0 + else + echo "No requisite pdb or psf files, exiting..." + exit 1 + fi + ;; + esac +} + + +function create_conf() { + + step_size=$((${final_step_num} - ${prev_step_num})) + + echo "Creating conf file using job:"${job}" system:"${system}" this_step:"$this_step" prev_step:$prev_step_num final_step:$final_step_num" + + ####################################################################################### + ## CREATE NAMD CONFIGURATION FILES ## + ####################################################################################### + + case "${this_step}" in + + ########################## + ## MINIMIZATION 1 ## + ########################## + "1-min") + + conf="${job}/${system}_${this_step}.conf" + out="${job}/${system}_${this_step}.out" + + echo "structure ${system}.psf" > ${conf} + echo "coordinates ${system}.pdb" >> ${conf} + echo "paraTypeCharmm on" >> ${conf} + for ff in "${ffs[@]}"; do + echo "parameters "${ff}"" >> ${conf} + done + echo "temperature 0" >> ${conf} + echo "" >> ${conf} + echo "# Force-Field Parameters" >> ${conf} + echo "exclude scaled1-4" >> ${conf} + echo "1-4scaling 1.0" >> ${conf} + echo "cutoff 12." >> ${conf} + echo "switching on" >> ${conf} + echo "switchdist 10." >> ${conf} + echo "pairlistdist 14" >> ${conf} + echo "" >> ${conf} + echo "# Integrator Parameters" >> ${conf} + echo "timestep 1.0 ;# 1fs/step" >> ${conf} + echo "nonbondedFreq 1" >> ${conf} + echo "fullElectFrequency 2" >> ${conf} + echo "stepspercycle 10" >> ${conf} + echo "" >> ${conf} + echo "# Output" >> ${conf} + echo "outputName ${system}_${this_step}" >> ${conf} + echo "outputEnergies 100" >> ${conf} + echo "outputPressure 100" >> ${conf} + # Minimize + echo "minimize 15000" >> ${conf} + ;; + ########################## + ## MINIMIZATION 2 ## + ########################## + "2-min") + + conf="${job}/${system}_${this_step}.conf" + out="${job}/${system}_${this_step}.out" + + # Solvate and ionize + solv_ion + + # create pcell.txt + calc_pcell_min2 + + # Source pcell.txt for PBC values + source "${job}/${system}_${this_step}_pcell.txt" + + # Begin writing NAMD conf file + echo "structure ${system}_solv_ion.psf" > ${conf} + echo "coordinates ${system}_solv_ion.pdb" >> ${conf} + echo "paraTypeCharmm on" >> ${conf} + for ff in "${ffs[@]}"; do + echo "parameters "${ff}"" >> ${conf} + done + echo "temperature 0" >> ${conf} + echo "" >> ${conf} + echo "# Periodic boundary conditions" >> ${conf} + echo "wrapWater on" >> ${conf} + echo "wrapAll on" >> ${conf} + echo "cellOrigin $CORX $CORY $CORZ" >> ${conf} + echo "cellBasisVector1 $CBVX 0.0 0.0" >> ${conf} + echo "cellBasisVector2 0.0 $CBVY 0.0" >> ${conf} + echo "cellBasisVector3 0.0 0.0 $CBVZ" >> ${conf} + echo "# Force-Field Parameters" >> ${conf} + echo "exclude scaled1-4" >> ${conf} + echo "1-4scaling 1.0" >> ${conf} + echo "cutoff 12." >> ${conf} + echo "switching on" >> ${conf} + echo "switchdist 10." >> ${conf} + echo "pairlistdist 14" >> ${conf} + echo "" >> ${conf} + echo "# Integrator Parameters" >> ${conf} + echo "timestep 2.0 ;# 2fs/step" >> ${conf} + echo "rigidBonds all ;# needed for 2fs steps" >> ${conf} + echo "nonbondedFreq 1" >> ${conf} + echo "fullElectFrequency 2" >> ${conf} + echo "stepspercycle 10" >> ${conf} + echo "" >> ${conf} + echo "# Output" >> ${conf} + echo "outputName ${system}_${this_step}" >> ${conf} + echo "outputEnergies 10000" >> ${conf} + echo "outputPressure 10000" >> ${conf} + # Minimize + echo "minimize 15000" >> ${conf} + ;; + ########################## + ## EQUILIBRATION ## + ########################## + "3-heat") + + conf="${job}/${system}_${this_step}.conf" + out="${job}/${system}_${this_step}.out" + + # create pcell.txt + calc_pcell_heat + + # Source pcell.txt for PBC values + source "${job}/${system}_${this_step}_pcell.txt" + + echo "structure ${system}_solv_ion.psf" > ${conf} + echo "coordinates ${system}_solv_ion.pdb" >> ${conf} + echo "bincoordinates ${system}_2-min.coor" >> ${conf} + echo "#extendedSystem ${system}_2-min.xsc" >> ${conf} + echo "cellOrigin $CORX $CORY $CORZ" >> ${conf} + echo "cellBasisVector1 $CBVX 0.0 0.0" >> ${conf} + echo "cellBasisVector2 0.0 $CBVY 0.0" >> ${conf} + echo "cellBasisVector3 0.0 0.0 $CBVZ" >> ${conf} + echo "" >> ${conf} + echo "firsttimestep ${prev_step_num}" >> ${conf} + echo "" >> ${conf} + echo "paraTypeCharmm on" >> ${conf} + for ff in "${ffs[@]}"; do + echo "parameters "${ff}"" >> ${conf} + done + echo "temperature 0" >> ${conf} + echo "#margin 2" >> ${conf} + echo "" >> ${conf} + echo "# Periodic boundary conditions" >> ${conf} + echo "wrapWater on" >> ${conf} + echo "wrapAll on" >> ${conf} + echo "" >> ${conf} + echo "# Full Electrostatics" >> ${conf} + echo "PME on" >> ${conf} + echo "PMEGridSpacing 1.0" >> ${conf} + echo "# Force-Field Parameters" >> ${conf} + echo "exclude scaled1-4" >> ${conf} + echo "1-4scaling 1.0" >> ${conf} + echo "cutoff 12." >> ${conf} + echo "switching on" >> ${conf} + echo "switchdist 10." >> ${conf} + echo "pairlistdist 14" >> ${conf} + echo "" >> ${conf} + echo "# Integrator Parameters" >> ${conf} + echo "timestep 2.0 ;# 2fs/step" >> ${conf} + echo "rigidBonds all ;# needed for 2fs steps" >> ${conf} + echo "nonbondedFreq 1" >> ${conf} + echo "fullElectFrequency 2 " >> ${conf} + echo "stepspercycle 10" >> ${conf} + echo "" >> ${conf} + echo "# Output" >> ${conf} + echo "outputName ${system}_${this_step}" >> ${conf} + echo "outputEnergies 1000" >> ${conf} + echo "outputPressure 1000" >> ${conf} + echo "dcdfreq 1000" >> ${conf} + echo "" >> ${conf} + echo "# Constant Temperature Control" >> ${conf} + echo "langevin on ;# do langevin dynamics" >> ${conf} + echo "langevinDamping 0.5 ;# damping coefficient (gamma) of 0.5/ps" >> ${conf} + echo "langevinTemp 310" >> ${conf} + echo "langevinHydrogen no ;# don't couple langevin bath to hydrogens" >> ${conf} + echo "" >> ${conf} + echo "# Constant Pressure Control (variable volume)" >> ${conf} + echo "useGroupPressure yes ;# needed for 2fs steps" >> ${conf} + echo "useFlexibleCell yes ;# no for water box, yes for membrane" >> ${conf} + echo "useConstantRatio yes ;# no for water box, yes for membrane" >> ${conf} + echo "langevinPiston on" >> ${conf} + echo "langevinPistonTarget 1.01325 ;# in bar -> 1 atm" >> ${conf} + echo "langevinPistonPeriod 100." >> ${conf} + echo "langevinPistonDecay 50." >> ${conf} + echo "langevinPistonTemp 310" >> ${conf} + echo "" >> ${conf} + # Equilibration loop + echo "set freq 100" >> ${conf} + echo 'for {set i 10} {$i <= 310} {incr i 10} {' >> ${conf} + echo 'reinitvels $i' >> ${conf} + echo 'langevinTemp $i' >> ${conf} + echo 'run $freq' >> ${conf} + echo '}' >> ${conf} + # Stabilize + echo 'run 10000' >> ${conf} + ;; + ########################## + ## SIMULATION ## + ########################## + "4-sim") + + conf="${job}/${system}_${this_step}_${final_step_num}.conf" + out="${job}/${system}_${this_step}_${final_step_num}.out" + + # Begin writing NAMD conf file + echo "structure ${system}_solv_ion.psf" > ${conf} + echo "coordinates ${system}_solv_ion.pdb" >> ${conf} + + # if this is the first timestep, begin with heat + if [[ ${prev_step_num} == 0 ]]; then + echo "temperature 310" >> ${conf} + echo "bincoordinates ${system}_3-heat.coor" >> ${conf} + # create pcell.txt + calc_pcell_heat + source "${job}/${system}_${this_step}_pcell.txt" + echo "cellOrigin $CORX $CORY $CORZ" >> ${conf} + echo "cellBasisVector1 $CBVX 0.0 0.0" >> ${conf} + echo "cellBasisVector2 0.0 $CBVY 0.0" >> ${conf} + echo "cellBasisVector3 0.0 0.0 $CBVZ" >> ${conf} + # else resume + else + echo "binvelocities ${system}_${this_step}_${prev_step_num}.vel" >> ${conf} + echo "bincoordinates ${system}_${this_step}_${prev_step_num}.coor" >> ${conf} + echo "extendedSystem ${system}_${this_step}_${prev_step_num}.xsc" >> ${conf} + fi + + echo "" >> ${conf} + echo "firsttimestep ${prev_step_num}" >> ${conf} + echo "" >> ${conf} + echo "#margin 2" >> ${conf} + echo "paraTypeCharmm on" >> ${conf} + for ff in "${ffs[@]}"; do + echo "parameters "${ff}"" >> ${conf} + done + echo "" >> ${conf} + echo "# Periodic boundary conditions" >> ${conf} + echo "wrapWater on" >> ${conf} + echo "wrapAll on" >> ${conf} + echo "" >> ${conf} + echo "# Full Electrostatics" >> ${conf} + echo "PME on" >> ${conf} + echo "PMEGridSpacing 1.0" >> ${conf} + echo "" >> ${conf} + echo "# Force-Field Parameters" >> ${conf} + echo "exclude scaled1-4" >> ${conf} + echo "1-4scaling 1.0" >> ${conf} + echo "cutoff 12." >> ${conf} + echo "switching on" >> ${conf} + echo "switchdist 10." >> ${conf} + echo "pairlistdist 14" >> ${conf} + echo "" >> ${conf} + echo "# Integrator Parameters" >> ${conf} + echo "timestep 2.0 ;# 2fs/step" >> ${conf} + echo "rigidBonds all ;# needed for 2fs steps" >> ${conf} + echo "nonbondedFreq 1" >> ${conf} + echo "fullElectFrequency 2 " >> ${conf} + echo "stepspercycle 10" >> ${conf} + echo "" >> ${conf} + echo "# Output" >> ${conf} + echo "outputName ${system}_${this_step}_${final_step_num}" >> ${conf} + echo "outputEnergies 10000" >> ${conf} + echo "outputPressure 10000" >> ${conf} + echo "dcdfreq 10000" >> ${conf} + echo "" >> ${conf} + echo "# Constant Temperature Control" >> ${conf} + echo "langevin on ;# do langevin dynamics" >> ${conf} + echo "langevinDamping 0.5 ;# damping coefficient (gamma) of 0.5/ps" >> ${conf} + echo "langevinTemp 310" >> ${conf} + echo "langevinHydrogen no ;# don't couple langevin bath to hydrogens" >> ${conf} + echo "" >> ${conf} + echo "# Constant Pressure Control (variable volume)" >> ${conf} + echo "useGroupPressure yes ;# needed for 2fs steps" >> ${conf} + echo "useFlexibleCell yes ;# no for water box, yes for membrane" >> ${conf} + echo "useConstantRatio yes ;# no for water box, yes for membrane" >> ${conf} + echo "langevinPiston on" >> ${conf} + echo "langevinPistonTarget 1.01325 ;# in bar -> 1 atm" >> ${conf} + echo "langevinPistonPeriod 100." >> ${conf} + echo "langevinPistonDecay 50." >> ${conf} + echo "langevinPistonTemp 310" >> ${conf} + echo "" >> ${conf} + echo "run ${step_size}" >> ${conf} + ;; + esac +} + +function solv_ion() { + # Create temporary VMD script to solvate, ionize, and generate PBC measurements + # Load molecule + echo "mol load psf [glob ${job}/${system}.psf] namdbin [glob ${job}/${system}_${prev_step}.coor]" > ${job}/temp_solv_ion.tcl + echo "set all [atomselect top all]" >> ${job}/temp_solv_ion.tcl + echo "\$all writepdb ${job}/${system}_${prev_step}.pdb" >> ${job}/temp_solv_ion.tcl + # Solvate + echo "package require solvate" >> ${job}/temp_solv_ion.tcl + echo "solvate ${job}/${system}.psf ${job}/${system}_${prev_step}.pdb -o ${job}/${system}_solv -s WT -x 13 -y 13 -z 13 +x 13 +y 13 +z 13 -b 2.4" >> ${job}/temp_solv_ion.tcl + # Ionize + echo "package require autoionize" >> ${job}/temp_solv_ion.tcl + echo "autoionize -psf ${job}/${system}_solv.psf -pdb ${job}/${system}_solv.pdb -o ${job}/${system}_solv_ion -sc 0.15" >> ${job}/temp_solv_ion.tcl + + # Run VMD + vmd -dispdev text -eofexit < "${job}/temp_solv_ion.tcl" + rm ${job}/temp_solv_ion.tcl +} + +function calc_pcell_min2() { + # Load molecule + echo "mol load psf [glob ${job}/${system}_solv_ion.psf] pdb [glob ${job}/${system}_solv_ion.pdb]" > ${job}/temp_build_box.tcl + + # Get PBC box measurements from VMD and output to pcell.txt + echo "set fileId [open ${job}/${system}_${this_step}_pcell.txt "w"]" >> ${job}/temp_build_box.tcl + echo "set all [atomselect top "not lipid"]" >> ${job}/temp_build_box.tcl + echo 'set minmax [measure minmax $all]' >> ${job}/temp_build_box.tcl + echo 'set vec [vecsub [lindex $minmax 1] [lindex $minmax 0]]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "#!/usr/bin/env bash"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVX=[lindex $vec 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVY=[lindex $vec 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVZ=[lindex $vec 2]"' >> ${job}/temp_build_box.tcl + echo 'set center [measure center $all]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORX=[lindex $center 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORY=[lindex $center 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORZ=[lindex $center 2]"' >> ${job}/temp_build_box.tcl + echo 'close $fileId' >> ${job}/temp_build_box.tcl + + # Run VMD + vmd -dispdev text -eofexit < "${job}/temp_build_box.tcl" + rm "${job}/temp_build_box.tcl" +} + +function calc_pcell_heat() { + # Load molecule + echo "mol load psf [glob ${job}/${system}_solv_ion.psf] namdbin [glob ${job}/${system}_${prev_step}.coor]" > ${job}/temp_build_box.tcl + + # Get PBC box measurements from VMD and output to pcell.txt + echo "set fileId [open ${job}/${system}_${this_step}_pcell.txt "w"]" >> ${job}/temp_build_box.tcl + echo "set all [atomselect top all]" >> ${job}/temp_build_box.tcl + echo 'set minmax [measure minmax $all]' >> ${job}/temp_build_box.tcl + echo 'set vec [vecsub [lindex $minmax 1] [lindex $minmax 0]]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "#!/usr/bin/env bash"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVX=[lindex $vec 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVY=[lindex $vec 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVZ=[lindex $vec 2]"' >> ${job}/temp_build_box.tcl + echo 'set center [measure center $all]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORX=[lindex $center 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORY=[lindex $center 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORZ=[lindex $center 2]"' >> ${job}/temp_build_box.tcl + echo 'close $fileId' >> ${job}/temp_build_box.tcl + + # Run VMD + vmd -dispdev text -eofexit < "${job}/temp_build_box.tcl" + rm "${job}/temp_build_box.tcl" +} + +function calc_pcell_sim() { + # Load molecule + echo "mol load psf [glob ${job}/${system}_solv_ion.psf] namdbin [glob ${job}/${system}_${prev_step}_${prev_step_num}.coor]" > ${job}/temp_build_box.tcl + + # Get PBC box measurements from VMD and output to pcell.txt + echo "set fileId [open ${job}/${system}_${this_step}_${prev_step_num}_pcell.txt "w"]" >> ${job}/temp_build_box.tcl + echo "set all [atomselect top all]" >> ${job}/temp_build_box.tcl + echo 'set minmax [measure minmax $all]' >> ${job}/temp_build_box.tcl + echo 'set vec [vecsub [lindex $minmax 1] [lindex $minmax 0]]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "#!/usr/bin/env bash"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVX=[lindex $vec 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVY=[lindex $vec 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CBVZ=[lindex $vec 2]"' >> ${job}/temp_build_box.tcl + echo 'set center [measure center $all]' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORX=[lindex $center 0]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORY=[lindex $center 1]"' >> ${job}/temp_build_box.tcl + echo 'puts $fileId "CORZ=[lindex $center 2]"' >> ${job}/temp_build_box.tcl + echo 'close $fileId' >> ${job}/temp_build_box.tcl + + # Run VMD + vmd -dispdev text -eofexit < "${job}/temp_build_box.tcl" + rm "${job}/temp_build_box.tcl" +} + +function copy_ffs() { + ffs=() + for ff in ../0-forcefields/*; do + if [[ -f "${ff}" ]]; then + # strip path + ff_name=${ff##*/} + # copy ff and append to ffs array + cp -f "${ff}" "${job}/${ff_name}" + ffs+=(${ff##*/}) + fi + done +} + +function backup() { + if [[ -f "${out}" ]]; then + mv "${out}" "${out}.bak" + fi +} + + diff --git a/auto_namd/hosts.sh b/auto_namd/hosts.sh new file mode 100755 index 0000000..a345eab --- /dev/null +++ b/auto_namd/hosts.sh @@ -0,0 +1,128 @@ +########################################## +## HOSTNAMES ## +########################################## + +function run_cheaha() { + echo "#!/usr/bin/env bash" > temp_sbatch + echo "#SBATCH --ntasks=${ntasks}" >> temp_sbatch + echo "#SBATCH --partition=${partition}" >> temp_sbatch + echo "#SBATCH --time=${time}" >> temp_sbatch + echo "#SBATCH --mem-per-cpu=${mem_per_cpu}" >> temp_sbatch + echo "#SBATCH --nodes=${nodes}" >> temp_sbatch + echo "#SBATCH --job-name=${job}_${this_step}_${final_step_num}" >> temp_sbatch + echo '# Load module(s)' >> temp_sbatch + echo 'module load rc/NAMD/2.12' >> temp_sbatch + + # generate temp NAMD nodelist + echo 'for n in `echo ${SLURM_NODELIST} | scontrol show hostnames`; do' >> temp_sbatch + echo ' echo "host $n ++cpus 24" >> ${TMPDIR}/nodelist.${SLURM_JOBID}' >> temp_sbatch + echo 'done' >> temp_sbatch + + # calculate ppn + echo 'PPN=$(expr $SLURM_NTASKS / $SLURM_NNODES - 1)' >> temp_sbatch + echo 'P="$(($PPN * $SLURM_NNODES))"' >> temp_sbatch + + # find namd location + echo 'namd_bin="$(which namd2)"' >> temp_sbatch + + echo "$(echo "${namd_param}") ${conf} > ${out}" >> temp_sbatch + + # cleanup temp NAMD nodelist + echo 'rm ${TMPDIR}/nodelist.${SLURM_JOBID}' >> temp_sbatch + + # submit using sbatch + sbatch temp_sbatch + rm temp_sbatch +} + +function run_workstation() { + $(echo "${namd_param}") ${conf} > ${out} + } + +function run_asc() { + job_name_pref=${job##*.}_${this_step}_${final_step_num} + + /apps/scripts/check_ssh + /apps/scripts/qquery program=namd input=$conf + + # create ~/.asc_queue + + echo 'start_time_pref=SOONEST' > ${HOME}/.asc_queue + echo "job_name_pref=${job_name_pref}" >> ${HOME}/.asc_queue + echo "queue_name_pref=${queue_name_pref}" >> ${HOME}/.asc_queue + echo "num_cpus_pref=${num_cpus_pref}" >> ${HOME}/.asc_queue + echo "cpu_time_pref=${cpu_time_pref}" >> ${HOME}/.asc_queue + echo "memory_pref=${memory_pref}" >> ${HOME}/.asc_queue + echo "cluster_pref=${cluster_pref}" >> ${HOME}/.asc_queue + + if [ -f qfile ] + then + read queue time memory sttime num_cpus < qfile + rm qfile + else + echo "ERROR: qfile not found" + echo " Make sure you have write permissions in this directory" + exit + fi + + # get limits + limits=`/apps/scripts/set_limits $time $num_cpus NA $memory NA NA` + + # get qos + qos=`/apps/scripts/set_qos $queue` + + # get constraints + constraints="--constraint=dmc|uv" # both clusters, not KNL + + echo '#!/usr/bin/env bash' > temp_sbatch + echo 'pwd="$(pwd)"' >> temp_sbatch + echo 'echo "pwd: $pwd"' >> temp_sbatch + echo '# set the workdir variable' >> temp_sbatch + echo "export workdir=/scratch/${LOGNAME}/${job##*./}" >> temp_sbatch + echo 'echo "workdir: $workdir"' >> temp_sbatch + echo '# load modules' >> temp_sbatch + echo 'source /opt/asn/etc/asn-bash-profiles-special/modules.sh' >> temp_sbatch + echo 'module purge' >> temp_sbatch + echo 'if [ ! -d $workdir ]' >> temp_sbatch + echo 'then' >> temp_sbatch + echo ' mkdir -p $workdir' >> temp_sbatch + echo 'fi' >> temp_sbatch + echo 'export TEMPDIR=$workdir' >> temp_sbatch + echo 'export TMPDIR=$workdir' >> temp_sbatch + echo 'export CONV_RSH=ssh' >> temp_sbatch + echo '# run from the current directory' >> temp_sbatch + echo "./cp_wild_r $job \$workdir" >> temp_sbatch + echo 'sleep 15' >> temp_sbatch + echo 'cd $workdir' >> temp_sbatch + echo 'export uv_test=`hostname | grep uv | wc -l`' >> temp_sbatch + echo 'export dmc_test=`hostname | grep dmc | wc -l`' >> temp_sbatch + echo '# code for the DMC' >> temp_sbatch + echo 'if [ $dmc_test == "1" ]' >> temp_sbatch + echo 'then' >> temp_sbatch + echo ' module purge' >> temp_sbatch + echo ' module load namd/2.12_ibverbs' >> temp_sbatch + echo ' namd_bin="$(which namd2)"' >> temp_sbatch + echo ' # run NAMD' >> temp_sbatch + echo ' alias mpiexec="srun"' >> temp_sbatch + echo " charmrun +p $num_cpus_pref ++mpiexec \${namd_bin} ${conf##*/} > ${out##*/}" >> temp_sbatch + echo 'fi' >> temp_sbatch + echo '# code for the UV' >> temp_sbatch + echo 'if [ "$uv_test" == "1" ]' >> temp_sbatch + echo 'then' >> temp_sbatch + echo ' module purge' >> temp_sbatch + echo ' module load namd/2.12' >> temp_sbatch + echo ' namd_bin="$(which namd2)"' >> temp_sbatch + echo ' # run NAMD' >> temp_sbatch + echo " charmrun +p $num_cpus_pref \${namd_bin} ${conf##*/} > ${out##*/}" >> temp_sbatch + echo 'fi' >> temp_sbatch + echo 'sleep 10' >> temp_sbatch + echo 'cd ${pwd}' >> temp_sbatch + echo "./cp_wild_r \$workdir $job" >> temp_sbatch + echo 'sleep 15' >> temp_sbatch + echo 'rm -r $workdir' >> temp_sbatch + echo 'exit 0' >> temp_sbatch + + sbatch $qos -J $job_name_pref --begin=$sttime --requeue $limits $constraints temp_sbatch + rm temp_sbatch + +} diff --git a/auto_namd/run.sh b/auto_namd/run.sh new file mode 100755 index 0000000..248c5a1 --- /dev/null +++ b/auto_namd/run.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +source ./functions.sh +source ./hosts.sh + +# ADJUSTABLE PARAMETERS +# set directory containing jobs to be run +jobs=( "../4-jobs/18_04_02/5w81-swiss*/" ) +step_size=1000000 +#repeats=50 + + +# FUNCTIONS +# remove trailing slashes from jobs array +jobs=(${jobs[@]%/}) + + +# HOSTNAME PARAMETERS +function run_namd() { + case "${HOSTNAME}" in + "phy145.physiology.uab.edu") # Workstation (local) + namd_param='/home/bryan/bin/namd/namd2 +p55 +idlepoll' + run_workstation + ;; + "login001") # Cheaha (Slurm) + namd_param='charmrun ++mpiexec ++nodelist ${TMPDIR}/nodelist.${SLURM_JOBID} +p ${SLURM_NTASKS} ${namd_bin}' + partition="short" + ntasks=96 + nodes=4 + time="12:00:00" + mem_per_cpu=128 + run_cheaha + ;; + "uv.asc.edu") # ASC (Slurm script) + namd_param="runnamd" + queue_name_pref="large" + num_cpus_pref=64 + cpu_time_pref="DEFAULT" + memory_pref="16gb" + cluster_pref='"uv|dmc"' + run_asc + ;; + *) # unknown + echo "You are running on an unknown system: \"${HOSTNAME}\"..." + echo "You must first add this machine to the resources section in run_namd.sh" + echo "Exiting..." + exit 1 + ;; + esac +} + + +# RUN LOOP + +for r in {1..50}; do + for job in "${jobs[@]}"; do + get_next_step + copy_ffs + create_conf + backup + run_namd + done +done