-
Notifications
You must be signed in to change notification settings - Fork 0
/
DCDHeader.f90
108 lines (78 loc) · 3.05 KB
/
DCDHeader.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
MODULE DcdHeader
! #DES: This module deals with the dcd file format's header, which contains a lt of information
IMPLICIT NONE
INTEGER :: unit
PRIVATE
PUBLIC :: parseHeader
CONTAINS
SUBROUTINE parseHeader(dcdUnit,debug,nAtoms,nFrames)
IMPLICIT NONE
INTEGER, INTENT(IN) :: dcdUnit
LOGICAL, INTENT(IN) :: debug
INTEGER, INTENT(OUT) :: nAtoms, nFrames
unit = dcdUnit
CALL parseHeaderLineOne(debug,nFrames)
CALL parseHeaderLineTwo(debug)
CALL parseHeaderLineThree(debug,nAtoms)
END SUBROUTINE parseHeader
!*
SUBROUTINE parseHeaderLineOne(debug,nFrames)
IMPLICIT NONE
LOGICAL, INTENT(IN) :: debug
INTEGER, INTENT(OUT) :: nFrames
INTEGER :: ios
CHARACTER(4) :: trajectoryType
INTEGER(4) :: nStepsBefore, interval, nSteps, intervalVelChek, na6, na7, nDegF
INTEGER(4) :: nFixed, na10, constP, na12, na13, na14, na15, na16, na17, na18, na19, charmmVersion
READ(unit,IOSTAT=ios) trajectoryType, nFrames, nStepsBefore, interval, nSteps, &
intervalVelChek, na6, na7, nDegF, nFixed, na10, constP, &
na12, na13, na14, na15, na16, na17, na18, na19, charmmVersion
IF (ios /= 0) STOP "Error reading first line of header"
IF (TRIM(ADJUSTL(trajectoryType)) /= 'CORD') STOP "Not a coordinate file"
IF (debug .EQV. .TRUE.) THEN
WRITE(*,*) "Trajectory Type: ", trajectoryType
WRITE(*,*) "Num. of Frames: ", nFrames
WRITE(*,*) "Num. Steps Before: ", nStepsBefore
WRITE(*,*) "Interval ", interval
WRITE(*,*) "Num. of Steps: ", nSteps
WRITE(*,*) "Interval Velocity Check: ", intervalVelChek
WRITE(*,*) "Degrees of Freedom: ", nDegF
WRITE(*,*) "Num. Fixed: ", nFixed
WRITE(*,*) "Constant Pressure: ", constP
WRITE(*,*) "CHARMM Version: ", charmmVersion
WRITE(*,*)
ENDIF
END SUBROUTINE parseHeaderLineOne
!*
SUBROUTINE parseHeaderLineTwo(debug)
IMPLICIT NONE
LOGICAL, INTENT(IN) :: debug
INTEGER :: ios
INTEGER, PARAMETER :: maxMaskRows = 20
INTEGER :: maskRows
CHARACTER(80) :: titlerow, topology, maskRow(maxMaskRows)
READ(unit,IOSTAT=ios) maskRows, titleRow, topology, maskRow(1:maskRows-2)
IF (ios /= 0) STOP "Error reading second line"
IF (titleRow(1:16) /= 'Q DCD trajectory') STOP "Not a Q trajectory file"
IF (debug .EQV. .TRUE.) THEN
WRITE(*,*)
WRITE(*,*) "Mask Rows: ", maskRows
WRITE(*,*) "Title Row: ", TRIM(ADJUSTL(titleRow))
WRITE(*,*) "Topology: ", TRIM(ADJUSTL(topology))
WRITE(*,*)
ENDIF
END SUBROUTINE parseHeaderLineTwo
!*
SUBROUTINE parseHeaderLineThree(debug,nAtoms)
IMPLICIT NONE
LOGICAL, INTENT(IN) :: debug
INTEGER, INTENT(OUT) :: nAtoms
INTEGER :: ios
READ(unit,IOSTAT=ios) nAtoms
IF (ios /= 0) STOP "Error reading third line"
IF (debug .EQV. .TRUE.) THEN
WRITE(*,*) "Atoms: ", nAtoms
WRITE(*,*)
ENDIF
END SUBROUTINE parseHeaderLineThree
END MODULE DcdHeader