Hello there! I would sincerely appreciate any advice you folks can offer, I've been trying to figure all this out for a while now with little luck. Though I have experience in C++ and FORTRAN I am pretty new to Tcl and am still trying to wrap my head around some of its features.
I have a series of files, named water_step_xxxxx.wat, where xxxxx is a five digit integer running by 2's from 00000 to 40000. These files each contain data in 2 columns generated by a FORTRAN program I wrote. The first column is in FORTRAN's f6.2 format (124.23, or 2.00 for instance) while the second is in f10.5 format.
I have thus far figured out how to open the files in a while loop, and have cobbled together the following sort of thing (file reading loop omitted for clarity) for reading the data into a variable:
set fp [open "C:\\wat\\water_step_00000.wat" r]
set file_data [read $fp]
close $fp
set data [split $file_data "\n"]
So my only real issue at this point (that I know of!) is how to get those columns of numbers into 2 separate arrays or lists. I know that the "format" statement exists in Tcl, but it doesn't appear to have the same functionality as in FORTRAN.
Can some kind soul share the most straightforward way to read the data from these .wat files into a list or array of numbers that I can then perform simple arithmetic with? Also, what type of variable would data be, in the code example above? I had assumed it would be an array, but none of the array specific commands appear to work with the data variable.
Thanks sincerely for any help you can provide, I'm hoping that perhaps there is some feature of Tcl that I am simply unfamiliar with that might help in this task.
I have a series of files, named water_step_xxxxx.wat, where xxxxx is a five digit integer running by 2's from 00000 to 40000. These files each contain data in 2 columns generated by a FORTRAN program I wrote. The first column is in FORTRAN's f6.2 format (124.23, or 2.00 for instance) while the second is in f10.5 format.
I have thus far figured out how to open the files in a while loop, and have cobbled together the following sort of thing (file reading loop omitted for clarity) for reading the data into a variable:
set fp [open "C:\\wat\\water_step_00000.wat" r]
set file_data [read $fp]
close $fp
set data [split $file_data "\n"]
So my only real issue at this point (that I know of!) is how to get those columns of numbers into 2 separate arrays or lists. I know that the "format" statement exists in Tcl, but it doesn't appear to have the same functionality as in FORTRAN.
Can some kind soul share the most straightforward way to read the data from these .wat files into a list or array of numbers that I can then perform simple arithmetic with? Also, what type of variable would data be, in the code example above? I had assumed it would be an array, but none of the array specific commands appear to work with the data variable.
Thanks sincerely for any help you can provide, I'm hoping that perhaps there is some feature of Tcl that I am simply unfamiliar with that might help in this task.