#!/bin/csh
#

# Generated by CHARMM-GUI (http://www.charmm-gui.org) v1.6

# This folder contains a pre-optimized PDB structure and OpenMM inputs.
# All input files were optimized for OpenMM v6.2 or above, so lower version of OpenMM can cause some errors.
# You can get the latest development version of OpenMM at the git repository:
# https://github.com/pandegroup/openmm


# Equilibration
# step6.[1-6]

set cnt = 1

while ( ${cnt} <= 6 )
        python openmm_run.py step6.${cnt}_equilibration.inp > step6.${cnt}_equilibration.out
        @ cnt += 1
end


# Production

# The OpenMM check point file (.chk) cannot be used in a different machine environment.
# So please make sure if you are using the same GPU and CUDA version of machine while doing additional
# production steps with the check point file.

set cnt = 1
set cntmax = 10

while ( ${cnt} <= ${cntmax} )
	if ( ${cnt} == 1 ) then
		set set1=`sed -n "/input_rst/"p step7_production.inp |awk '{print $2, $3}'`
		set set2=`sed -n "/input_chk/"p step7_production.inp |awk '{print $2, $3}'`
		set set3=`sed -n "/output_dcd/"p step7_production.inp |awk '{print $3}'`
		set set4=`sed -n "/output_chk/"p step7_production.inp |awk '{print $3}'`
		sed -i -e "/input_rst/s/${set1}/= step6.6_equilibration.rst/g" -e "/input_chk/s/${set2}/=/g" -e "/output_dcd/s/${set3}/step7_${cnt}.dcd/g" -e "/output_chk/s/${set4}/step7_${cnt}.chk/g" step7_production.inp
	else
		@ pcnt = ${cnt} - 1
		set set1=`sed -n "/input_rst/"p step7_production.inp |awk '{print $2, $3}'`
		set set2=`sed -n "/input_chk/"p step7_production.inp |awk '{print $2, $3}'`
		set set3=`sed -n "/output_dcd/"p step7_production.inp |awk '{print $3}'`
		set set4=`sed -n "/output_chk/"p step7_production.inp |awk '{print $3}'`
		sed -i -e "/input_rst/s/${set1}/=/g" -e "/input_chk/s/${set2}/= step7_${pcnt}.chk/g" -e "/output_dcd/s/${set3}/step7_${cnt}.dcd/g" -e "/output_chk/s/${set4}/step7_${cnt}.chk/g" step7_production.inp
	endif
	python openmm_run.py step7_production.inp > step7_${cnt}.out
	@ cnt += 1
end
