restart conflict with preminim
[django_unres.git] / django_simple / todo / views.py
index e1ac2b0..d38312f 100644 (file)
@@ -910,6 +910,17 @@ def restart(request, task_id):
     task = get_object_or_404(Task, id=task_id)
     restart0(task)
     return redirect('/')
+   
+def add_restart_inp():
+    with open('file.inp','r') as f1, open ('file.inp.tmp','w') as f2:
+        for line in f1:
+          if 'reset_vel=' in line:
+            f2.write('{:79}'.format('restart'+line[7:]))
+          else:
+            f2.write(line)
+    os.remove('file.inp')
+    os.rename('file.inp.tmp','file.inp')
+    return 
     
 def restart0(task):    
     if os.path.isfile(task.jobdirname+'/finished'):    
@@ -920,10 +931,12 @@ def restart0(task):
     task.save()
     if task.type == 'md':
       os.chdir(task.jobdirname)
+      add_restart_inp()
       ret_code = subprocess.Popen(' /opt/torque/bin/qsub pbs.csh', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)            
       os.chdir('..')
     elif task.type == 'remd':
       os.chdir(task.jobdirname)
+      add_restart_inp()
       tmp1=json.loads(task.remd_multi_m)
       nreplicas=sum(map(int, tmp1))
       with open('file_wham.inp','r') as f1, open ('file_wham.tmp','w') as f2: