-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.f90
50 lines (35 loc) · 1.13 KB
/
output.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
module output
implicit none
contains
subroutine write_out(pos,vel,acc,mass,h,dens,u,pres,n,num,t)
integer, intent(in) :: n,num
real, dimension(:), intent(in) :: pos,vel,acc,mass,h,dens,u,pres
real, intent(in) :: t
integer :: i
character(len=20) :: filename
write(filename,'(A,I5.5,A)') 'dumps_',num,'.out'
open(unit=1,file=filename,status='replace')
write(1,*) t
do i=1,n
write(1,*) pos(i),vel(i),acc(i),mass(i),h(i),dens(i),u(i),pres(i)
enddo
close(1)
print*, 'Particles at t = ', t, ' written successfully to ', filename
end subroutine write_out
subroutine write_ev_out(vel,mass,n,t)
use toolkit, only:maxtime,evwrite
use energy, only:kinetic_energy
integer, intent(in) :: n
real, intent(in) :: t
real, dimension(:), intent(in) :: vel,mass
character(len=20) :: filename
write(filename,'(A)') 'energy.ev'
if (t < tiny(t)) then
open(unit=evwrite,file=filename,status='replace')
endif
write(evwrite,*) t, kinetic_energy(vel,mass,n)
if (t >= maxtime) then
close(evwrite)
endif
end subroutine write_ev_out
end module output