How to read in data?

Posted by: bqcao

How to read in data? - 02/05/04 02:47 PM

Dear All,

I want to read in some external data and transfer them to an array, my data file is like below:

1 2.33
2 3.21
.. ...

I expect to read in them as x(i) and y(i), respectively. Could anyone please help me? I read io.doc, but I didn't find any clues there. Thanks!

Best,
Cao
Posted by: lennart

Re: How to read in data? - 02/06/04 03:20 AM

Hi,
This is perhaps not so easy to find in the documentation, but you can use the GET command (miscom.doc). You have to have your data in files with one item per line:
* reading data from file into vector
*
open unit 21 read form name x.dat
open unit 22 read form name y.dat

set i 1
label loop
get x@@i unit 21
if x@@i eq END-OF-FILE goto done
get y@@i unit 22
incr i by 1
goto loop
label done

set j 3
set k 5
write title unit 6
* @x1 @y1
* @x2 @y2
* @x@@j @y@@j
* @x@@k @y@@k
*

If you absolutely want to read several datapoints per line you can modify the code in source/charmm/miscom.src and recompile.

Good Luck!
Posted by: BRBrooks

Re: How to read in data? - 02/07/04 01:55 AM

You can also read and manipulate arbitrary arrays of data in correl (see correl.doc).

There is also the universal coordinate reader if the data is related to the number of atoms.... (see io.doc)