Difference between revisions of "Makerestart"

From CUC3
Jump to navigation Jump to search
import>Csw34
import>Csw34
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
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:
+
GMIN creates a file, ''GMIN.dump'' every 1000 steps which allows you to restart the run if, for example, your job crashed of if you simply want to run more quenches to see if you find a lower minimum. 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''
 
* ''input.crd''
Line 5: Line 5:
 
* ''GMIN.dump'' - if your run crashed and you only have ''GMIN.dump.save'', copy it to GMIN.dump and then run the script
 
* ''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!
+
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! The usage is extremely simple, copy the below text into your favourite editor and save it as ''makerestart''. You then need to make it executable and I recommend moving it into your ''bin'' directory i.e.
 
  +
chmod a+x makerestart
  +
mv makerestart ~/bin
   
  +
Now change to the directory containing your [[GMIN]] output and type:
NOTE: I had to put a lot of hashes in as for some reason the wiki was splitting the code into blocks when I had blank lines there :( Anyone know how to fix that?
 
   
 
makerestart <number of steps in restart run>
#!/bin/bash
 
  +
#
 
  +
That should do it!
###########################################################################
 
  +
# Created by Chris Whittleston (csw34@cam.ac.uk) on 9th May 2008 ##
 
  +
<pre>
# Script to setup a restart run for GMIN ##
 
 
#!/bin/bash
# Usage: './makerestart <number of steps>' ##
 
  +
# e.g. if you want to do another 1000 steps then use './makerestart 1000'##
 
###########################################################################
+
###########################################################################
 
# Created by Chris Whittleston (csw34@cam.ac.uk) on 9th May 2008 ##
#
 
 
# Script to setup a restart run for GMIN ##
# VARIABLE ASSIGNMENT
 
 
# Usage: './makerestart <number of steps>' ##
#
 
 
# e.g. if you want to do another 1000 steps then use './makerestart 1000'##
# 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
 
 
# VARIABLE ASSIGNMENT
# This increments the $steps variable by the number used in the first arguement
 
  +
let "steps += $1"
 
 
# 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'})
# SOME PRINTING
 
 
steps=$oldsteps
#
 
 
# This increments the $steps variable by the number used in the first arguement
echo 'Setting up restart run in the current directory'
 
echo 'Number of steps completed='$oldsteps
+
let "steps += $1"
  +
echo 'Number of additional steps requested='$1
 
 
# SOME PRINTING
echo 'Total number of steps after restart='$steps
 
  +
#
 
 
echo 'Setting up restart run in the current directory'
# CREATING THE NEW DATA FILE
 
  +
echo 'Number of steps completed='$oldsteps
#
 
 
echo 'Number of additional steps requested='$1
# NOTE that the last sed command ensures that if the data file has been used in a restart run before,
 
  +
echo 'Total number of steps after restart='$steps
# 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'
 
 
# CREATING THE NEW DATA FILE
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
 
 
# NOTE that the last sed command ensures that if the data file has been used in a restart run before,
echo 'STEPS '$steps' 1.0' >> data.top
 
 
# the 'RESTORE' line is removed to ensure it only appears once in the new file!
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
+
# 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
# FILE HANDLING
 
 
echo 'STEPS '$steps' 1.0' >> data.top
#
 
 
echo 'RESTORE GMIN.dump' >> data.top
mkdir restart
 
 
# Adds the bottom bit of the data file back on (NOT including the 'STEPS' line from the old one)
cp GMIN.dump input.crd restart/
 
sed -n '2,$p' data.top > restart/data
+
awk '/STEPS/,0' data | sed -n '2,$p' | sed -n '/RESTORE/!p' >> data.top
  +
rm data.top
 
 
# FILE HANDLING
  +
 
mkdir restart
 
cp GMIN.dump input.crd restart/
  +
sed -n '2,$p' data.top > restart/data
 
rm data.top
  +
</pre>
  +
You should now have a subdirectory called ''restart'' where you ran the script. Running [[GMIN]] here will begin the restart run. Also, the script is designed so that you can of course run it in the directory of a previous restart run!

Latest revision as of 15:14, 14 May 2008

GMIN creates a file, GMIN.dump every 1000 steps which allows you to restart the run if, for example, your job crashed of if you simply want to run more quenches to see if you find a lower minimum. 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! The usage is extremely simple, copy the below text into your favourite editor and save it as makerestart. You then need to make it executable and I recommend moving it into your bin directory i.e.

chmod a+x makerestart
mv makerestart ~/bin

Now change to the directory containing your GMIN output and type:

makerestart <number of steps in restart run>

That should do it!

#!/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

You should now have a subdirectory called restart where you ran the script. Running GMIN here will begin the restart run. Also, the script is designed so that you can of course run it in the directory of a previous restart run!