5 program ghostcell_benchmark_3d
10 integer,
parameter :: n_boxes_base = 1
11 integer,
parameter :: n_var_cell = 1
12 integer,
parameter :: i_phi = 1
15 type(ref_info_t) :: ref_info
17 integer :: n_cell, it, n_iterations, max_ref_lvl
18 integer :: ix_list(3, n_boxes_base)
20 character(len=100) :: arg_string
21 integer :: count_rate, t_start, t_end
23 print *,
"Running ghostcell_benchmark_3d" 24 print *,
"Number of threads", af_get_max_threads()
27 n_args = command_argument_count()
30 call get_command_argument(1, arg_string)
31 read(arg_string, *) n_cell
33 print *,
"No arguments specified, using default values" 34 print *,
"Usage: ./ghostcell_benchmark_3d n_cell max_ref_lvl n_iterations" 40 call get_command_argument(2, arg_string)
41 read(arg_string, *) max_ref_lvl
47 call get_command_argument(3, arg_string)
48 read(arg_string, *) n_iterations
53 print *,
"Box size: ", n_cell
54 print *,
"Max refinement lvl: ", max_ref_lvl
55 print *,
"Num iterations: ", n_iterations
69 ix_list(:, 1) = [1, 1, 1]
72 call a3_set_base(tree, 1, ix_list)
74 call system_clock(t_start, count_rate)
77 call a3_loop_box(tree, set_init_cond)
83 call a3_adjust_refinement(tree, ref_routine, ref_info)
86 if (ref_info%n_add == 0)
exit 88 call system_clock(t_end, count_rate)
90 write(*,
"(A,Es10.3,A)")
" Wall-clock time generating AMR grid: ", &
91 (t_end-t_start) /
real(count_rate,dp),
" seconds" 93 call a3_print_info(tree)
96 call system_clock(t_start, count_rate)
97 do it = 1, n_iterations
98 call a3_gc_tree(tree, i_phi, a3_gc_interp, a3_bc_dirichlet_zero, .false.)
100 call system_clock(t_end, count_rate)
102 time = (t_end-t_start) /
real(count_rate, dp)
103 write(*,
"(A,I0,A,E10.3,A)") &
104 " Wall-clock time after ", n_iterations, &
105 " iterations: ", time,
" seconds" 106 write(*,
"(A,E10.3,A)")
" Per iteration: ", time/n_iterations,
" seconds" 111 subroutine ref_routine(box, cell_flags)
112 type(box3_t),
intent(in) :: box
113 integer,
intent(out) :: cell_flags(box%n_cell, box%n_cell, box%n_cell)
116 if (box%lvl < max_ref_lvl)
then 117 cell_flags = af_do_ref
119 cell_flags = af_keep_ref
121 end subroutine ref_routine
124 subroutine set_init_cond(box)
125 type(box3_t),
intent(inout) :: box
129 box%cc(1:nc, 1:nc, 1:nc, i_phi) = 1.0_dp
130 end subroutine set_init_cond
132 end program ghostcell_benchmark_3d
Module which contains all Afivo modules, so that a user does not have to include them separately...