Makerestart

From CUC3
Revision as of 12:01, 9 May 2008 by import>Csw34
Jump to navigation Jump to search

This script can be run in a directory containing the output from a CGMIN run to automatically setup a restart. The directory you run it in must include the following files:

  • input.crd
  • data
  • GMIN.dump - if your run crashed and you only have GMIN.dump.save, copy it to GMIN.dump and then run the script

This script works for CHARMM with GMIN only but it is very simple to modify it for use with AMBER! All you need to change is the files that are copied across in the file handling section!

#!/bin/bash
###########################################################################
# Created by Chris Whittleston (csw34@cam.ac.uk) on 9th May 2008         ##
# Script to setup a restart run for GMIN                                 ##
# Usage: './makerestart <number of steps>'                               ##
# e.g. if you want to do another 1000 steps then use './makerestart 1000'##
###########################################################################
# VARIABLE ASSIGNMENT
# Prints the line in the data file containing 'STEPS' and assigns $oldsteps to the second column
oldsteps=$(sed -n '/STEPS/p' data | awk '{print $2'})
steps=$oldsteps
# This increments the $steps variable by the number used in the first arguement 
let "steps += $1"
# SOME PRINTING 
echo 'Setting up restart run in the current directory'
echo 'Number of steps completed='$oldsteps
echo 'Number of additional steps requested='$1
echo 'Total number of steps after restart='$steps
# CREATING THE NEW DATA FILE 
# NOTE that the last sed command ensures that if the data file has been used in a restart run before,
# the 'RESTORE' line is removed to ensure it only appears once in the new file!
# Prints the top of the data file up to (but not including) the line containing 'STEPS' to a new file, 'data.top'
awk 'NR==1,/STEPS/{print x};{x=$0}' data | sed -n '/RESTORE/!p' > data.top
# Adds back in the 'STEPS' keyword and also the 'RESTORE' command to specify a restart
echo 'STEPS '$steps' 1.0' >> data.top
echo 'RESTORE GMIN.dump' >> data.top
# Adds the bottom bit of the data file back on (NOT including the 'STEPS' line from the old one)
awk '/STEPS/,0' data | sed -n '2,$p' | sed -n '/RESTORE/!p' >> data.top
# FILE HANDLING
mkdir restart
cp GMIN.dump input.crd restart/
sed -n '2,$p' data.top > restart/data
rm data.top