-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_dcd.f90
69 lines (57 loc) · 1.72 KB
/
read_dcd.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
program read_header
use m_npy
! Data declarations
INTEGER*4 NTITL, ICNTRL(20),NATOM
CHARACTER(100) :: filename, outfile, max_at_str
CHARACTER*4 HDR
CHARACTER*80 TITLE(2) !(NTITL)
INTEGER :: i, dir, iframe, iatom, max_at
REAL*4, allocatable :: coord_x(:), coord_y(:), coord_z(:)
REAL*4, allocatable :: coor(:,:,:)
IF(COMMAND_ARGUMENT_COUNT().NE. 3) THEN
write(*,*) "No max_at supplied, all atoms will be considered"
end if
call get_command_argument(1, filename)
call get_command_argument(2, outfile)
call get_command_argument(3, max_at_str)
open(unit=56, file=filename, form='unformatted')
read(56) HDR,icntrl
read(56) NTITL, (TITLE(i), i=1,NTITL)
read(56) natom
WRITE(*,*) "TYPE OF FILE: ", HDR
WRITE(*,*) "NUMBER OF FRAMES IN FILE:", ICNTRL(1)
write(*,*) "NUMBER OF ATOMS IN SYS:", natom
if (ICNTRL(11).EQ.1) then
write(*,*) "CRYSTAL LATTICE INFO PRESENT"
end if
if (COMMAND_ARGUMENT_COUNT().EQ.3) then
READ(max_at_str,*) max_at
natom = max_at
write(*,*)
write(*,*) "Only the first", max_at, "atoms will be considered!"
else
max_at = natom
end if
!ICNTRL(1) = 750000.0 IF HEADER DOES NOT CONTAIN THE CORRECT # OF FRAMES
allocate(coor(ICNTRL(1), 3, natom))
allocate(coord_x(natom))
allocate(coord_y(natom))
allocate(coord_z(natom))
if (ICNTRL(9).EQ.1) then
read(56) ! fixed atom adds another header line (?)
end if
do iframe=1, ICNTRL(1)
if (ICNTRL(11).EQ.1) then
read(56) ! CELL DATA (?)
end if
read(56) coord_x
read(56) coord_y
read(56) coord_z
coor(iframe, 1, :) = coord_x(1:max_at)
coor(iframe, 2, :) = coord_y(1:max_at)
coor(iframe, 3, :) = coord_z(1:max_at)
end do
call save_npy(outfile, coor)
write(*,*)
write(*,*) "COORDINATES WRITTEN TO ", outfile
end program read_header