From: preeda (preeda_at_hlab.iis.u-tokyo.ac.jp)
Date: Mon Apr 23 2007 - 12:07:59 CDT

Dear John and other VMD users,

Thank you for your advice about using trace function to retrieve force
data.

I wrote a tcl file name "saveforce.tcl" to use trace function by calling
vmd_frame, now force data can be printed out continuously during
simulation runs but I can not save these force data into a file. Output
file is created but nothing inside; it seems like a problem about
opening and closing file channelId.
Here is my code "saveforce.tcl"

set pullatoms "index 1"
set sel [atomselect top "$pullatoms"]

set outfilename [open output.dat w]

proc trace {} {
      global vmd_frame
      trace variable vmd_frame w IMD::tracetimestep
}

proc IMD::tracetimestep {args} {
  global cen sel outfilename
  set force [$sel get {ufx ufy ufz}]
  puts "force = $force"
  # output
  puts $outfilename "$force"
  close $outfilename
}

Do you know what I did wrong? Any advice will be greatly appreciated.

Best Regards,

Preeda