Previous Thread
Next Thread
Print Thread
How to read in data?
#897 02/05/04 07:47 PM
Joined: Dec 2003
Posts: 8
bqcao Offline OP
Forum Member
OP Offline
Forum Member
Joined: Dec 2003
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!

Best,
Cao

Re: How to read in data?
bqcao #898 02/06/04 08:20 AM
Joined: Sep 2003
Posts: 4,762
Forum Member
Offline
Forum Member
Joined: Sep 2003
Posts: 4,762
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!


Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden
Re: How to read in data?
bqcao #899 02/07/04 06:55 AM
Joined: Sep 2003
Posts: 394
Forum Member
Offline
Forum Member
Joined: Sep 2003
Posts: 394
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)


Moderated by  John Legato, lennart 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 5.6.33-0+deb8u1 Page Time: 0.009s Queries: 20 (0.003s) Memory: 0.9022 MB (Peak: 0.9764 MB) Data Comp: Off Server Time: 2020-04-10 07:09:25 UTC
Valid HTML 5 and Valid CSS