33 use,
intrinsic :: iso_fortran_env, only: stdin=>input_unit&
34 , stdout=>output_unit&
43 integer,
parameter :: real64 = selected_real_kind(15)
47 subroutine print_loc(my_rank, maximum_rank, my_location, number_of_processes)
48 integer,
intent(in) :: my_rank, maximum_rank
49 integer,
dimension(3),
intent(in) :: my_location, number_of_processes
50 integer :: rank, error
51 do rank=0, maximum_rank-1
52 if(rank == my_rank)
then
53 write(stdout,
'(a,i3.3,a,i3,",",i3,",",i3,a,i3,",",i3,",",i3,a)')&
54 "[", my_rank,
"] Location: (", my_location,
")/(", number_of_processes,
")"
56 call mpi_barrier(mpi_comm_world, error)
58 call mpi_barrier(mpi_comm_world, error)
63 subroutine print_domain(my_rank, maximum_rank, domain_vertices)
64 integer,
intent(in) :: my_rank, maximum_rank
65 real(real64),
dimension(3,2),
intent(in) :: domain_vertices
66 integer :: rank, error
67 do rank=0, maximum_rank-1
68 if(rank == my_rank)
then
69 write(stdout,
'("[",i3.3,"]",a,es12.4,a,es12.4,a,es12.4)')&
71 domain_vertices(1,1), achar(9),&
72 domain_vertices(2,1), achar(9),&
74 write(stdout,
'("[",i3.3,"]",a,es12.4,a,es12.4,a,es12.4)')&
76 domain_vertices(1,2), achar(9),&
77 domain_vertices(2,2), achar(9),&
80 call mpi_barrier(mpi_comm_world,error)
82 call mpi_barrier(mpi_comm_world,error)
87 subroutine print_work(my_rank, maximum_rank, my_work)
88 integer,
intent(in) :: my_rank, maximum_rank
89 real(real64),
intent(in) :: my_work
90 integer :: rank, error
91 do rank=0, maximum_rank-1
92 if(rank == my_rank)
then
93 write(stdout,
'(a,i3.3,a,es12.4)')&
94 "[", my_rank,
"] Work: ", my_work
96 call mpi_barrier(mpi_comm_world, error)
98 call mpi_barrier(mpi_comm_world, error)
104 integer,
intent(in) :: my_rank, maximum_rank, timestep
105 real(real64),
dimension(3,2),
intent(in) :: new_vertices
106 integer :: rank, error
107 do rank=0, maximum_rank-1
108 if(rank == my_rank)
then
113 write(stdout,
'(a,i4,",",i3.3,",",i2.2,a,3f11.6)')&
114 "[", timestep, my_rank, 0,
"] Result Vertex: ",&
117 write(stdout,
'(a,i4,",",i3.3,",",i2.2,a,3f11.6)')&
118 "[", timestep, my_rank, 1,
"] Result Vertex: ",&
121 call mpi_barrier(mpi_comm_world, error)
123 call mpi_barrier(mpi_comm_world, error)
128 subroutine print_binary(my_rank, my_work, new_vertices, my_location, number_of_processes, fh, timestep)
129 use iso_fortran_env,
only: error_unit
132 integer,
intent(in) :: fh
133 integer,
dimension(MPI_STATUS_SIZE) :: state
135 type(mpi_file),
intent(in) :: fh
136 type(mpi_status) :: state
138 integer,
intent(in) :: my_rank, timestep
139 integer,
dimension(3),
intent(in) :: my_location, number_of_processes
140 real(real64),
intent(in) :: my_work
141 real(real64),
dimension(3,2),
intent(in) :: new_vertices
142 integer(MPI_OFFSET_KIND) :: offset
143 real(real64),
dimension(11) :: buffer
146 offset = ((timestep-1) * number_of_processes(3) * 11 + my_rank * 11) * 8
148 buffer(1) = real(my_rank,real64)
150 buffer(3) = new_vertices(1,1)
151 buffer(4) = new_vertices(2,1)
152 buffer(5) = new_vertices(3,1)
153 buffer(6) = new_vertices(1,2)
154 buffer(7) = new_vertices(2,2)
155 buffer(8) = new_vertices(3,2)
156 buffer(9) = my_location(1)
157 buffer(10) = my_location(2)
158 buffer(11) = my_location(3)
160 call mpi_file_write_at(fh, offset, buffer, 11, mpi_double_precision, state, error);
167 integer :: current_step
168 integer,
parameter :: number_of_steps = 50
169 integer,
parameter :: dimensions = 3
170 real(real64),
parameter :: loadbalancer_gamma = 0.
171 integer,
dimension(dimensions) :: my_location, number_of_processes
172 real(real64),
dimension(dimensions) :: minimum_domain_size
173 real(real64),
dimension(dimensions,2) :: domain_vertices, new_vertices
174 real(real64),
parameter :: domain_size = 1.0
175 real(real64) :: my_work
176 integer :: my_rank, maximum_rank
183 character(256),
dimension(:),
allocatable :: clargs
184 character(256) :: filename, filename2
185 integer(MPI_OFFSET_KIND) :: offset
190 integer,
dimension(MPI_STATUS_SIZE) :: state
193 type(mpi_status) :: state
196#ifdef ALL_VTK_OUTPUT_EXAMPLE
197 character (len=ALL_ERROR_LENGTH) :: error_msg
204 call jall%init(
all_staggered, dimensions, loadbalancer_gamma)
207 call mpi_comm_rank(mpi_comm_world, my_location(3), error)
208 my_rank = my_location(3)
210 number_of_processes(:) = 1
211 call mpi_comm_size(mpi_comm_world, number_of_processes(3), error)
212 maximum_rank = number_of_processes(3)
214 n_clargs = command_argument_count()
215 if (n_clargs > 1)
then
216 call get_command_argument(2,clargs(2))
217 write(filename,
"(a,i0,a)") trim(clargs(2)),number_of_processes,trim(
".bin")
219 write(filename,
"(a,i0,a)") trim(
"./ALL_Staggered_f_"),number_of_processes(3),trim(
".bin")
221 call mpi_file_open(mpi_comm_world,filename,ior(mpi_mode_create, mpi_mode_wronly), mpi_info_null, fh, error)
223 if(my_rank == 0)
then
224 write(stdout,
'(a,i0)')
"Ranks: ", maximum_rank
225 write(stdout,
'(a,i0)')
"Number of Steps: ", number_of_steps
229 call mpi_barrier(mpi_comm_world, error)
230 call print_loc(my_rank, maximum_rank, my_location, number_of_processes)
234 call jall%set_proc_grid_params(my_location, number_of_processes)
237 minimum_domain_size(:) = 0.1
238 call jall%set_min_domain_size(minimum_domain_size)
240 call jall%set_communicator(mpi_comm_world)
247 call jall%set_proc_tag(my_rank)
258 domain_vertices(j,i) = (my_location(j)+i-1) * domain_size
261 call print_domain(my_rank, maximum_rank, domain_vertices)
262 call jall%set_vertices(domain_vertices)
265 my_work = my_rank + 1.
266 call jall%set_work(my_work)
267 call print_work(my_rank, maximum_rank, my_work)
268 do current_step=1, number_of_steps
271 if(my_rank == 0)
then
272 write(stdout,
'(a,i0,"/",i0)')
"Starting step: ", current_step, number_of_steps
275#ifdef ALL_VTK_OUTPUT_EXAMPLE
277 call jall%print_vtk_outlines(current_step)
280 write(stdout,
'(a)') error_msg
283 call mpi_abort(mpi_comm_world, 2, error)
289 call jall%get_vertices(new_vertices)
292 call print_binary(my_rank, my_work, new_vertices, my_location, number_of_processes, fh, current_step)
294 call mpi_barrier(mpi_comm_world, error)
296#ifdef ALL_VTK_OUTPUT_EXAMPLE
298 call jall%print_vtk_outlines(current_step)
301 write(stdout,
'(a)') error_msg
304 call mpi_abort(mpi_comm_world, 2, error)
310 call mpi_file_close(fh, error)
312 call mpi_finalize(error)
void print_loc(int rank, int *loc, int *size)
int main(int argc, char **argv)
void print_binary(int step, int rank, double work, std::vector< ALL::Point< double > > &vertices, int *loc, int *size, MPI_File fh)
void print_testing_output(int rank, std::vector< ALL::Point< double > > &vertices, int timestep)
void print_domain(int rank, double *verts)
void print_work(int rank, double work)
The function API for ALL.
integer(c_int), parameter, public all_staggered
integer function, public all_error()
subroutine, public all_reset_error()
character(len=all_error_length) function, public all_error_description()
The object oriented API is this object. It contains all relevant functions.