Difference between revisions of "Makerestart"

From CUC3
Jump to navigation Jump to search
import>Csw34
import>Csw34
 
(8 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:
#!/bin/bash
 
   
 
makerestart <number of steps in restart run>
###########################################################################
 
# 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'##
 
###########################################################################
 
   
  +
That should do it!
# Variable assignment
 
   
  +
<pre>
## Prints the line in the data file containing 'STEPS' and assigns $oldsteps to the second column
 
 
#!/bin/bash
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
 
 
# 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
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
 
   
 
# Prints the line in the data file containing 'STEPS' and assigns $oldsteps to the second column
# CREATING THE NEW DATA FILE
 
 
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
# 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
 
   
 
echo 'Setting up restart run in the current directory'
# FILE HANDLING
 
 
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
mkdir restart
 
  +
cp GMIN.dump input.crd restart/
 
 
# NOTE that the last sed command ensures that if the data file has been used in a restart run before,
sed -n '2,$p' data.top > restart/data
 
 
# the 'RESTORE' line is removed to ensure it only appears once in the new file!
rm 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
 
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
  +
</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!