Topic Options
#897 - 02/05/04 02:47 PM How to read in data?
bqcao Offline
Forum Member

Registered: 12/31/03
Posts: 8
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!


#898 - 02/06/04 03:20 AM Re: How to read in data? [Re: bqcao]
lennart Online   content

Forum Member

Registered: 09/25/03
Posts: 4761
Loc: ~ 59N, 15E
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!
Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden

#899 - 02/07/04 01:55 AM Re: How to read in data? [Re: bqcao]
BRBrooks Offline

Forum Member

Registered: 09/02/03
Posts: 394
Loc: Rockville, Maryland
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)


Moderator:  John Legato, lennart