forked from lgcrego/Dynemol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_MM.f
116 lines (89 loc) · 3.22 KB
/
backup_MM.f
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
108
109
110
111
112
113
114
115
116
module Backup_MM_m
use type_m , only : dynemolworkdir
use parameters_m , only : restart
use MM_types , only : MM_system , MM_atomic
public :: Security_Copy_MM , Restart_MM
contains
!
!
!
!===============================================
subroutine Security_Copy_MM( MM , atom , frame )
!===============================================
implicit none
type(MM_system) , intent(in) :: MM
type(MM_atomic) , intent(in) :: atom(:)
integer , intent(in) :: frame
! local variables ...
integer :: i , j
logical , save :: first_time = .true.
logical :: exist
real :: start_time, end_time
! check whether restart is properly set ...
call CPU_TIME(start_time)
If( first_time ) then
If( restart ) then
inquire( file=dynemolworkdir//"Security_copy_MM.dat", EXIST=exist )
If( exist ) stop " <Security_copy_MM.dat> exists; check restart parameter or move Security_copy_MM.dat to Restart_copy_MM.dat"
else
inquire( file="Restart_copy_MM.dat", EXIST=exist )
If( exist ) stop " <Restart_copy_MM.dat> exists; check restart parameter or delete Restart_copy_MM.dat"
end If
! get rid of Restart_copy_MM.dat for new Security_copy_MM.dat ...
inquire( file=dynemolworkdir//"Restart_copy_MM.dat", EXIST=exist )
If( exist ) CALL system( "rm Restart_copy_MM.dat" )
first_time = .false.
end If
open(unit=33, file="ancillary.trunk/Security_copy_MM.dat", status="unknown", form="unformatted", action="write")
write(33) frame
write(33) MM % N_of_atoms
do i = 1 , 3
write(33) MM % box(i)
end do
do i = 1 , size(atom)
write(33) atom(i) % charge
write(33) atom(i) % MM_charge
do j = 1 , 3
write(33) atom(i) % xyz(j)
write(33) atom(i) % vel(j)
write(33) atom(i) % ftotal(j)
end do
end do
close( 33 )
call CPU_TIME(end_time)
print *, 'Total Security_Copy execution time: ', end_time - start_time, ' seconds'
end subroutine Security_Copy_MM
!
!
!
!=========================================
subroutine Restart_MM( MM , atom , frame )
!=========================================
implicit none
type(MM_system) , intent(inout) :: MM
type(MM_atomic) , intent(inout) :: atom(:)
integer , intent(out) :: frame
! local variables ...
integer :: i , j , file_err
open(unit=33, file="Restart_copy_MM.dat", form="unformatted", status="old", action="read" , iostat=file_err , err=11 )
read(33) frame
read(33) MM % N_of_atoms
do i = 1 , 3
read(33) MM % box(i)
end do
do i = 1 , size(atom)
read(33) atom(i) % charge
read(33) atom(i) % MM_charge
do j = 1 , 3
read(33) atom(i) % xyz(j)
read(33) atom(i) % vel(j)
read(33) atom(i) % ftotal(j)
end do
end do
close( 33 )
11 if( file_err > 0 ) stop " <Restart_copy_MM.dat> file not found; terminating execution; mv Security_copy_MM.dat Restart_copy_MM.dat "
end subroutine Restart_MM
!
!
!
end module Backup_MM_m