-
Notifications
You must be signed in to change notification settings - Fork 0
/
rms_vel_3d.F90
76 lines (61 loc) · 2.18 KB
/
rms_vel_3d.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
program rms_vel_3d_program
use amr_utils
character (LEN=:), allocatable :: output_basedir
character (LEN=:), allocatable :: ioutput_str
integer :: ioutput
integer :: length
integer :: ilevel, ind, i
integer :: igrid, ngrid
double precision :: vsqd_sum
! We only need 'next' and 'u'
keep_father=.FALSE.
keep_next=.TRUE.
keep_prev=.FALSE.
keep_level=.FALSE.
keep_flag1=.FALSE.
keep_cpu_map=.FALSE.
keep_nbor=.FALSE.
keep_xg=.FALSE.
keep_u=.TRUE.
! Only store u,v,w
min_ivar = 2
max_ivar = 4
if (command_argument_count() /= 2) then
write (6,*) "Wrong number of command line arguments (expecting 2)!"
write (6,*) "First argument: directory containing RAMSES outputs"
write (6,*) "Second argument: output number of desired output"
stop 1
end if
call get_command_argument(1, length=length)
allocate(character(LEN=length) :: output_basedir)
call get_command_argument(1, output_basedir)
call get_command_argument(2, length=length)
allocate(character(LEN=length) :: ioutput_str)
call get_command_argument(2, ioutput_str)
read(ioutput_str, *) ioutput
call read_all(output_basedir, ioutput)
if (.NOT. (keep_next .AND. keep_u)) then
stop "Need 'next' and 'u' data!"
end if
vsqd_sum = 0.d0
ngrid = -1
do ilevel=nlevelmax, 1, -1
ngrid = numbl(ilevel)
if (ngrid==0) cycle
! Otherwise we have found the lowest level with cells
igrid = headl(ilevel)
do i=1,ngrid
do ind=1,twotondim
vsqd_sum = vsqd_sum + sum(u(igrid, ind, 2:4)**2)
end do
igrid = next(igrid)
end do
exit ! only do the lowest occupied level (assume fixed grid)
end do
if (ngrid == -1) then
stop "We didn't find any cells!"
end if
vsqd_sum = vsqd_sum / dble(twotondim)
vsqd_sum = vsqd_sum / dble(ngrid)
write(6,*) "rms velocity: ", sqrt(vsqd_sum)
end program rms_vel_3d_program