10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 12:23:43 +01:00

Read only the n first atoms in xyz

This commit is contained in:
Anthony Scemama 2020-05-29 00:11:10 +02:00
parent 59b05ff39d
commit 2208d58c58
2 changed files with 14 additions and 13 deletions

View File

@ -13,11 +13,8 @@ dev:
bugfix:
A fork of the *master* on which the bug fixes are made.
dev-lcpq:
Toulouse development branch
dev-lct:
Paris development branch
dev:
Development branch
gh-pages:
This is an independent branch, containing only the web site of QP2.

View File

@ -149,14 +149,18 @@ let of_xyz_file
let lines =
match Io_ext.input_lines filename with
| natoms :: title :: rest ->
begin
let natoms =
try
if (int_of_string @@ String_ext.strip natoms) <= 0 then
raise XYZError
int_of_string @@ String_ext.strip natoms
with
| _ -> raise XYZError
end;
String.concat "\n" rest
in
if natoms <= 0 then
raise XYZError;
let a = Array.of_list rest in
Array.sub a 0 natoms
|> Array.to_list
|> String.concat "\n"
| _ -> raise XYZError
in
of_xyz_string ~charge:charge ~multiplicity:multiplicity