Buffering problems while attempting to read log file

From: Zach Hensel (zhensel_at_gmail.com)
Date: Fri Feb 10 2006 - 11:08:29 CST

Hello,

I am trying to implement replica exchange by interfacing NAMD
simulations with a Tcl server on our local cluster. At the moment I'm
having trouble reading the energy of the replicas reliably. The .conf
file runs a command to grab the energies of the replica after a period
of simulation:

set energies [split [exec tail -15 replica.log | grep ENERGY | awk {{
print $12,$11 }}]]
set potE [expr [lindex $energies 0] - [lindex $energies 1]]

... potential energies are sent to the Tcl server which calculates
exchange moves and returns new temperatures to replicas ...

This "works" on occasion, but runs into problems because the log file
is not fully updated. Viewing the log file with tail -f as it is
created shows that the output is caught up in some buffer. I'm not
sure if this namd's buffer before sending information to stdout or
some buffer implicit in redirecting namd output to a log file.

It seems like there has to be an easy fix to this:
1. Some way to read potential energy within namd without loading any
new coordinates files
2. A way to flush the output before reading the log file

Any help would be appreciated.

Zach Hensel
Johns Hopkins Biophysics

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:43:17 CST