-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaida.f90
197 lines (184 loc) · 7.84 KB
/
saida.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
module saida
contains
subroutine vec2csv(v,n,d,prop,step,t,nimpre,start,concat0)
use mod1
!N é o número de partículas e d é a dimensão da propriedade
! cada linha é uma partícula
implicit none
logical, optional :: concat0
logical :: laux
integer, intent(in) :: n,d
real(dp), allocatable, intent(in) :: v(:,:)
real(dp), intent(in) :: t, start !, v(n,d)
integer :: i,step, nimpre, ic1, cpu_countrate, horas, min
real(dp) :: sec
character(*) :: prop
character(4) :: extensao = '.csv'
character(6) :: passo
real(dp) :: time
real(dp), save :: timep, etc, dtimepp
character(LEN=*),parameter :: fmt5 = '(f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16 )'
character(LEN=*),parameter :: fmt6 = '(i10, ", ",i10, ", ",f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16 )'
character(LEN=*),parameter :: fmt7 = &
'(f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16, ", ",f32.16 )'
laux = .false.
if (present(concat0)) laux = concat0
write(passo,'(i0)') step
if (d <= 3) then
open(10,file='temp/'//prop//extensao//'.'//trim(passo),status="replace")
else
open(10,file='temp2/'//prop//extensao//'.'//trim(passo),status="replace")
end if
if (.not. laux) then
if (d == 1) then
do i = 1,n
write(10,*) v(i,1)
end do
else if (d == 2) then
do i = 1,n
write(10,*) v(i,1),',',v(i,2)
end do
else if (d == 3) then
do i = 1,n
write(10,*) v(i,1),',',v(i,2),',',v(i,3)
end do
else if (d == 4) then
do i = 1,n
write(10,*) v(i,1),',',v(i,2),',',v(i,3),',',v(i,4)
end do
else if (d == 5) then
do i = 1,n
write(10,fmt5) v(i,1),v(i,2),v(i,3),v(i,4),v(i,5)
end do
else if (d == 6) then
do i = 1,n
write(10,fmt6) int(v(i,1)),int(v(i,2)),v(i,3),v(i,4),v(i,5),v(i,6)
end do
else if (d == 7) then
do i = 1,n
write(10,fmt7) v(i,1),v(i,2),v(i,3),v(i,4),v(i,5),v(i,6),v(i,7)
end do
end if
else
if (d == 1) then
do i = 1,n
write(10,*) v(i,1),',',0
end do
else if (d == 2) then
do i = 1,n
write(10,*) v(i,1),',',v(i,2),',',0
end do
else if (d == 3) then
do i = 1,n
write(10,*) v(i,1),',',v(i,2),',',v(i,3),',',0
end do
else if (d == 4) then
do i = 1,n
write(10,fmt5) v(i,1),v(i,2),v(i,3),v(i,4),0
end do
else if (d == 5) then
do i = 1,n
write(10,fmt6) v(i,1),v(i,2),v(i,3),v(i,4),v(i,5),0
end do
else if (d == 6) then
do i = 1,n
write(10,fmt7) v(i,1),v(i,2),v(i,3),v(i,4),v(i,5),v(i,6),0
end do
end if
end if
close(10)
if (prop == "position") then
if (step == 0) timep = 0
! call cpu_time(time)
call system_clock(ic1,cpu_countrate)
time = real(ic1,kind(0.d0))/real(cpu_countrate,kind(0.d0))
if (step == 2) then
call system_clock(ic1,cpu_countrate)
time = real(ic1,kind(0.d0))/real(cpu_countrate,kind(0.d0))
etc = ((time - start)/real(step,kind(0.d0)) + (time-timep))*0.5*real(nimpre,kind(0.d0)) - (time - start)
dtimepp = (time-timep)
print '("Salvo arquivo ", A, " t = ", f12.3, " ETC: ", f10.3, "s" )',prop//extensao//'.'//trim(passo),t,etc
else if (step > 2) then
call system_clock(ic1,cpu_countrate)
time = real(ic1,kind(0.d0))/real(cpu_countrate,kind(0.d0))
etc = ((time - start)*6/real(step,kind(0.d0)) + ((time-timep)*2 + dtimepp*2))* &
(real(nimpre,kind(0.d0))-real(step,kind(0.d0)))/10
horas = int(etc/3600)
min = (int(etc) - horas*3600)/60
sec = etc - real(horas*3600 + min*60,kind(0.d0))
print '("Salvo arquivo ", A, " t = ", f12.3, " ETC: ", i3,":",i2,":",f4.1 )' &
,prop//extensao//'.'//trim(passo),t,horas, min, sec
dtimepp = (time-timep)
else
print '("Salvo arquivo ", A, " t = ", f12.3, " ETC: ", "unknown" )',prop//extensao//'.'//trim(passo),t
end if
timep = time
else
if (step > 2) then
print '("Salvo arquivo ", A, " t = ", f12.3, " ETC: ", f10.3, "s" )',prop//extensao//'.'//trim(passo),t,etc
else
print '("Salvo arquivo ", A, " t = ", f12.3, " ETC: ", "unknown" )',prop//extensao//'.'//trim(passo),t
end if
! time = real(ic1,kind(0.d0))/real(cpu_countrate,kind(0.d0))
! timep = time
end if
! print*, 'Salvo arquivo ',prop//extensao//'.'//trim(passo), "t =", t, "ETC: ", etc
end subroutine vec2csv
subroutine linked2vec(malha,mesh,domx,domy,nxv,aux1)
use linkedlist
use mod1
use data
use mod0
type(container), allocatable,dimension(:,:),intent(in) :: malha
integer :: i,j,aux1
integer, intent(in) :: domx(2), domy(2), mesh(2)
type(list_t), pointer :: node
real(dp), intent(out) :: nxv(:)
type(data_ptr) :: ptr
aux1 = 1
! real(dp),intent(inout) :: celula(:,:)
do i = domy(1), domy(2)
do j = domx(1), domx(2)
if(i > 1 .and. i < mesh(2)+2 .and. j > 1 .and. j < mesh(1)+2) then
node => list_next(malha(i,j)%list)
do while (associated(node))
ptr = transfer(list_get(node), ptr)
nxv(aux1:aux1+4) = [ real(ptr%p%n, kind(0.d0)), ptr%p%x(1),ptr%p%x(2), &
ptr%p%v(1), ptr%p%v(2)]
aux1 = aux1 + 5
node => list_next(node)
end do
end if
end do
end do
aux1 = aux1 -1
end subroutine linked2vec
subroutine nancheck(malha,mesh,t)
use linkedlist
use mod1
use data
use mod0
real(dp), intent(in) :: t
integer :: i
integer, intent(in) :: mesh(:)
type(container), allocatable,dimension(:,:),intent(in) :: malha
type(data_ptr) :: ptr
type(list_t), pointer :: node
do i = 1,mesh(2)+2
do j = 1,mesh(1)+2
node => list_next(malha(i,j)%list)
do while (associated(node))
ptr = transfer(list_get(node), ptr)
!calcula a energia cinética atual
node => list_next(node)
if (isnan(ptr%p%x(1))) then
print*, 'NaN em part',ptr%p%n,'x, t=',t
end if
if (isnan(ptr%p%x(2))) then
print*, 'NaN em part',ptr%p%n,'y, t=',t
end if
end do
end do
end do
end subroutine nancheck
end module saida