44 integer,
intent(in) :: ierr
47 if (ierr /= mpi_success)
then
75 integer,
intent(in) :: status
80 call mpi_abort(mpi_comm_world, status, ierr)
95 call mpi_finalize(ierr)
107 integer,
intent(in),
optional :: comm
110 integer :: ierr, l_comm
112 if (
present(comm))
then
115 l_comm = mpi_comm_world
118 call mpi_barrier(l_comm, ierr)
130 integer,
intent(in),
optional :: comm
133 integer :: rank, ierr, l_comm
135 if (
present(comm))
then
138 l_comm = mpi_comm_world
141 call mpi_comm_rank(l_comm, rank, ierr)
156 integer,
intent(in),
optional :: comm
159 integer :: size, ierr, l_comm
161 if (
present(comm))
then
164 l_comm = mpi_comm_world
167 call mpi_comm_size(l_comm,
size, ierr)
182 real(kind=dp),
parameter :: test_real = 2.718281828459d0
183 complex(kind=dc),
parameter :: test_complex &
184 = (0.707106781187d0, 1.4142135624d0)
185 logical,
parameter :: test_logical = .true.
186 character(len=100),
parameter :: test_string &
187 =
"a truth universally acknowledged"
188 integer,
parameter :: test_integer = 314159
190 character,
allocatable :: buffer(:)
191 integer :: buffer_size, max_buffer_size, position
192 real(kind=dp) :: send_real, recv_real
193 complex(kind=dc) :: send_complex, recv_complex
194 logical :: send_logical, recv_logical
195 character(len=100) :: send_string, recv_string
196 integer :: send_integer, recv_integer
197 real(kind=dp),
allocatable :: send_real_array(:)
198 real(kind=dp),
allocatable :: recv_real_array(:)
201 send_real = test_real
202 send_complex = test_complex
203 send_logical = test_logical
204 send_string = test_string
205 send_integer = test_integer
206 allocate(send_real_array(2))
207 send_real_array(1) = real(test_complex)
208 send_real_array(2) = aimag(test_complex)
211 max_buffer_size = max_buffer_size &
213 max_buffer_size = max_buffer_size &
215 max_buffer_size = max_buffer_size &
217 max_buffer_size = max_buffer_size &
219 max_buffer_size = max_buffer_size &
221 max_buffer_size = max_buffer_size &
224 allocate(buffer(max_buffer_size))
233 call assert_msg(350740830, position <= max_buffer_size, &
234 "MPI test failure: pack position " &
236 //
" greater than max_buffer_size " &
238 buffer_size = position
244 allocate(buffer(buffer_size))
257 call assert_msg(787677020, position == buffer_size, &
258 "MPI test failure: unpack position " &
260 //
" not equal to buffer_size " &
267 call assert_msg(567548916, recv_real == test_real, &
268 "MPI test failure: real recv " &
270 //
" not equal to " &
272 call assert_msg(653908509, recv_complex == test_complex, &
273 "MPI test failure: complex recv " &
275 //
" not equal to " &
277 call assert_msg(307746296, recv_logical .eqv. test_logical, &
278 "MPI test failure: logical recv " &
280 //
" not equal to " &
282 call assert_msg(155693492, recv_string == test_string, &
283 "MPI test failure: string recv '" &
284 // trim(recv_string) &
285 //
"' not equal to '" &
286 // trim(test_string) //
"'")
287 call assert_msg(875699427, recv_integer == test_integer, &
288 "MPI test failure: integer recv " &
290 //
" not equal to " &
292 call assert_msg(326982363,
size(recv_real_array) == 2, &
293 "MPI test failure: real array recv size " &
295 //
" not equal to 2")
297 recv_real_array(1) == real(test_complex), &
298 "MPI test failure: real array recv index 1 " &
300 //
" not equal to " &
303 recv_real_array(2) == aimag(test_complex), &
304 "MPI test failure: real array recv index 2 " &
306 //
" not equal to " &
319 integer,
intent(inout) :: val
321 integer,
intent(in),
optional :: comm
324 integer :: root, ierr, l_comm
326 if (
present(comm))
then
329 l_comm = mpi_comm_world
333 call mpi_bcast(val, 1, mpi_integer, root, &
346 character(len=*),
intent(inout) :: val
348 integer,
intent(in),
optional :: comm
351 integer :: root, ierr, l_comm
353 if (
present(comm))
then
356 l_comm = mpi_comm_world
360 call mpi_bcast(val, len(val), mpi_character, root, &
373 character,
intent(inout) :: val(:)
375 integer,
intent(in),
optional :: comm
378 integer :: root, ierr, l_comm
380 if (
present(comm))
then
383 l_comm = mpi_comm_world
387 call mpi_bcast(val,
size(val), mpi_character, root, &
400 integer,
intent(in) :: val
402 integer,
intent(in),
optional :: comm
404 integer :: ierr, l_comm
407 if (
present(comm))
then
410 l_comm = mpi_comm_world
413 call mpi_pack_size(1, mpi_integer, l_comm, &
428 real(kind=dp),
intent(in) :: val
430 integer,
intent(in),
optional :: comm
432 integer :: ierr, l_comm
435 if (
present(comm))
then
438 l_comm = mpi_comm_world
441 call mpi_pack_size(1, mpi_double_precision, l_comm, &
456 character(len=*),
intent(in) :: val
458 integer,
intent(in),
optional :: comm
460 integer :: ierr, l_comm
463 if (
present(comm))
then
466 l_comm = mpi_comm_world
469 call mpi_pack_size(len_trim(val), mpi_character, l_comm, &
486 logical,
intent(in) :: val
488 integer,
intent(in),
optional :: comm
490 integer :: ierr, l_comm
493 if (
present(comm))
then
496 l_comm = mpi_comm_world
499 call mpi_pack_size(1, mpi_logical, l_comm, &
514 complex(kind=dc),
intent(in) :: val
516 integer,
intent(in),
optional :: comm
518 integer :: ierr, l_comm
521 if (
present(comm))
then
524 l_comm = mpi_comm_world
527 call mpi_pack_size(1, mpi_double_complex, l_comm, &
542 integer,
allocatable,
intent(in) :: val(:)
544 integer,
intent(in),
optional :: comm
546 integer :: total_size, ierr, l_comm
549 logical :: is_allocated
551 if (
present(comm))
then
554 l_comm = mpi_comm_world
558 is_allocated =
allocated(val)
559 if (is_allocated)
then
560 call mpi_pack_size(
size(val), mpi_integer, l_comm, &
580 real(kind=dp),
allocatable,
intent(in) :: val(:)
582 integer,
intent(in),
optional :: comm
584 integer :: total_size, ierr, l_comm
587 logical :: is_allocated
589 if (
present(comm))
then
592 l_comm = mpi_comm_world
596 is_allocated =
allocated(val)
597 if (is_allocated)
then
598 call mpi_pack_size(
size(val), mpi_double_precision, l_comm, &
618 character(len=*),
allocatable,
intent(in) :: val(:)
620 integer,
intent(in),
optional :: comm
622 integer :: i, total_size, l_comm
624 logical :: is_allocated
626 if (
present(comm))
then
629 l_comm = mpi_comm_world
632 is_allocated =
allocated(val)
633 if (is_allocated)
then
653 real(kind=dp),
allocatable,
intent(in) :: val(:,:)
655 integer,
intent(in),
optional :: comm
657 integer :: total_size, ierr, l_comm
660 logical :: is_allocated
662 if (
present(comm))
then
665 l_comm = mpi_comm_world
669 is_allocated =
allocated(val)
670 if (is_allocated)
then
671 call mpi_pack_size(
size(val), mpi_double_precision, l_comm, &
674 total_size = total_size &
693 character,
intent(inout) :: buffer(:)
695 integer,
intent(inout) :: position
697 integer,
intent(in) :: val
699 integer,
intent(in),
optional :: comm
702 integer :: prev_position, ierr, l_comm
704 if (
present(comm))
then
707 l_comm = mpi_comm_world
710 prev_position = position
711 call mpi_pack(val, 1, mpi_integer, buffer,
size(buffer), &
712 position, l_comm, ierr)
726 character,
intent(inout) :: buffer(:)
728 integer,
intent(inout) :: position
730 real(kind=dp),
intent(in) :: val
732 integer,
intent(in),
optional :: comm
735 integer :: prev_position, ierr, l_comm
737 if (
present(comm))
then
740 l_comm = mpi_comm_world
743 prev_position = position
744 call mpi_pack(val, 1, mpi_double_precision, buffer,
size(buffer), &
745 position, l_comm, ierr)
759 character,
intent(inout) :: buffer(:)
761 integer,
intent(inout) :: position
763 character(len=*),
intent(in) :: val
765 integer,
intent(in),
optional :: comm
768 integer :: prev_position, length, ierr, l_comm
770 if (
present(comm))
then
773 l_comm = mpi_comm_world
776 prev_position = position
777 length = len_trim(val)
779 call mpi_pack(val, length, mpi_character, buffer,
size(buffer), &
780 position, l_comm, ierr)
794 character,
intent(inout) :: buffer(:)
796 integer,
intent(inout) :: position
798 logical,
intent(in) :: val
800 integer,
intent(in),
optional :: comm
803 integer :: prev_position, ierr, l_comm
805 if (
present(comm))
then
808 l_comm = mpi_comm_world
811 prev_position = position
812 call mpi_pack(val, 1, mpi_logical, buffer,
size(buffer), &
813 position, l_comm, ierr)
827 character,
intent(inout) :: buffer(:)
829 integer,
intent(inout) :: position
831 complex(kind=dc),
intent(in) :: val
833 integer,
intent(in),
optional :: comm
836 integer :: prev_position, ierr, l_comm
838 if (
present(comm))
then
841 l_comm = mpi_comm_world
844 prev_position = position
845 call mpi_pack(val, 1, mpi_double_complex, buffer,
size(buffer), &
846 position, l_comm, ierr)
860 character,
intent(inout) :: buffer(:)
862 integer,
intent(inout) :: position
864 integer,
allocatable,
intent(in) :: val(:)
866 integer,
intent(in),
optional :: comm
869 integer :: prev_position, n, ierr, l_comm
870 logical :: is_allocated
872 if (
present(comm))
then
875 l_comm = mpi_comm_world
878 prev_position = position
879 is_allocated =
allocated(val)
881 if (is_allocated)
then
884 call mpi_pack(val, n, mpi_integer, buffer,
size(buffer), &
885 position, l_comm, ierr)
889 position - prev_position <= &
901 character,
intent(inout) :: buffer(:)
903 integer,
intent(inout) :: position
905 real(kind=dp),
allocatable,
intent(in) :: val(:)
907 integer,
intent(in),
optional :: comm
910 integer :: prev_position, n, ierr, l_comm
911 logical :: is_allocated
913 if (
present(comm))
then
916 l_comm = mpi_comm_world
919 prev_position = position
920 is_allocated =
allocated(val)
922 if (is_allocated)
then
925 call mpi_pack(val, n, mpi_double_precision, buffer,
size(buffer), &
926 position, l_comm, ierr)
941 character,
intent(inout) :: buffer(:)
943 integer,
intent(inout) :: position
945 character(len=*),
allocatable,
intent(in) :: val(:)
947 integer,
intent(in),
optional :: comm
950 integer :: prev_position, i, n, l_comm
951 logical :: is_allocated
953 if (
present(comm))
then
956 l_comm = mpi_comm_world
959 prev_position = position
960 is_allocated =
allocated(val)
962 if (is_allocated)
then
970 position - prev_position <= &
982 character,
intent(inout) :: buffer(:)
984 integer,
intent(inout) :: position
986 real(kind=dp),
allocatable,
intent(in) :: val(:,:)
988 integer,
intent(in),
optional :: comm
991 integer :: prev_position, n1, n2, ierr, l_comm
992 logical :: is_allocated
994 if (
present(comm))
then
997 l_comm = mpi_comm_world
1000 prev_position = position
1001 is_allocated =
allocated(val)
1003 if (is_allocated)
then
1008 call mpi_pack(val, n1*n2, mpi_double_precision, buffer,
size(buffer), &
1009 position, l_comm, ierr)
1013 position - prev_position <= &
1025 character,
intent(inout) :: buffer(:)
1027 integer,
intent(inout) :: position
1029 integer,
intent(out) :: val
1031 integer,
intent(in),
optional :: comm
1034 integer :: prev_position, ierr, l_comm
1036 if (
present(comm))
then
1039 l_comm = mpi_comm_world
1042 prev_position = position
1043 call mpi_unpack(buffer,
size(buffer), position, val, 1, mpi_integer, &
1060 character,
intent(inout) :: buffer(:)
1062 integer,
intent(inout) :: position
1064 real(kind=dp),
intent(out) :: val
1066 integer,
intent(in),
optional :: comm
1069 integer :: prev_position, ierr, l_comm
1071 if (
present(comm))
then
1074 l_comm = mpi_comm_world
1077 prev_position = position
1078 call mpi_unpack(buffer,
size(buffer), position, val, 1, &
1079 mpi_double_precision, l_comm, ierr)
1084 val = real(0.0, kind=dp)
1095 character,
intent(inout) :: buffer(:)
1097 integer,
intent(inout) :: position
1099 character(len=*),
intent(out) :: val
1101 integer,
intent(in),
optional :: comm
1104 integer :: prev_position, length, ierr, l_comm
1106 if (
present(comm))
then
1109 l_comm = mpi_comm_world
1112 prev_position = position
1114 call assert(946399479, length <= len(val))
1116 call mpi_unpack(buffer,
size(buffer), position, val, length, &
1117 mpi_character, l_comm, ierr)
1133 character,
intent(inout) :: buffer(:)
1135 integer,
intent(inout) :: position
1137 logical,
intent(out) :: val
1139 integer,
intent(in),
optional :: comm
1142 integer :: prev_position, ierr, l_comm
1144 if (
present(comm))
then
1147 l_comm = mpi_comm_world
1150 prev_position = position
1151 call mpi_unpack(buffer,
size(buffer), position, val, 1, mpi_logical, &
1168 character,
intent(inout) :: buffer(:)
1170 integer,
intent(inout) :: position
1172 complex(kind=dc),
intent(out) :: val
1174 integer,
intent(in),
optional :: comm
1177 integer :: prev_position, ierr, l_comm
1179 if (
present(comm))
then
1182 l_comm = mpi_comm_world
1185 prev_position = position
1186 call mpi_unpack(buffer,
size(buffer), position, val, 1, &
1187 mpi_double_complex, l_comm, ierr)
1203 character,
intent(inout) :: buffer(:)
1205 integer,
intent(inout) :: position
1207 integer,
allocatable,
intent(inout) :: val(:)
1209 integer,
intent(in),
optional :: comm
1212 integer :: prev_position, n, ierr, l_comm
1213 logical :: is_allocated
1215 if (
present(comm))
then
1218 l_comm = mpi_comm_world
1221 prev_position = position
1223 if (
allocated(val))
deallocate(val)
1224 if (is_allocated)
then
1227 call mpi_unpack(buffer,
size(buffer), position, val, n, mpi_integer, &
1232 position - prev_position <= &
1244 character,
intent(inout) :: buffer(:)
1246 integer,
intent(inout) :: position
1248 real(kind=dp),
allocatable,
intent(inout) :: val(:)
1250 integer,
intent(in),
optional :: comm
1253 integer :: prev_position, n, ierr, l_comm
1254 logical :: is_allocated
1256 if (
present(comm))
then
1259 l_comm = mpi_comm_world
1262 prev_position = position
1264 if (
allocated(val))
deallocate(val)
1265 if (is_allocated)
then
1268 call mpi_unpack(buffer,
size(buffer), position, val, n, &
1269 mpi_double_precision, l_comm, ierr)
1273 position - prev_position <= &
1285 character,
intent(inout) :: buffer(:)
1287 integer,
intent(inout) :: position
1289 character(len=*),
allocatable,
intent(inout) :: val(:)
1291 integer,
intent(in),
optional :: comm
1294 integer :: prev_position, i, n, l_comm
1295 logical :: is_allocated
1297 if (
present(comm))
then
1300 l_comm = mpi_comm_world
1303 prev_position = position
1305 if (
allocated(val))
deallocate(val)
1306 if (is_allocated)
then
1314 position - prev_position <= &
1326 character,
intent(inout) :: buffer(:)
1328 integer,
intent(inout) :: position
1330 real(kind=dp),
allocatable,
intent(inout) :: val(:,:)
1332 integer,
intent(in),
optional :: comm
1335 integer :: prev_position, n1, n2, ierr, l_comm
1336 logical :: is_allocated
1338 if (
present(comm))
then
1341 l_comm = mpi_comm_world
1344 prev_position = position
1346 if (
allocated(val))
deallocate(val)
1347 if (is_allocated)
then
1350 allocate(val(n1,n2))
1351 call mpi_unpack(buffer,
size(buffer), position, val, n1*n2, &
1352 mpi_double_precision, l_comm, ierr)
1355 call assert(781681739, position - prev_position &
1368 real(kind=dp),
intent(in) :: val
1370 real(kind=dp),
intent(out) :: val_avg
1375 call mpi_reduce(val, val_avg, 1, mpi_double_precision, mpi_sum, 0, &
1376 mpi_comm_world, ierr)
1393 real(kind=dp),
intent(in) :: from_val
1395 real(kind=dp),
intent(out) :: to_val
1397 integer,
intent(in) :: from_proc
1399 integer,
intent(in) :: to_proc
1402 integer :: rank, ierr, status(MPI_STATUS_SIZE)
1405 if (from_proc == to_proc)
then
1406 if (rank == from_proc)
then
1410 if (rank == from_proc)
then
1411 call mpi_send(from_val, 1, mpi_double_precision, to_proc, &
1412 208020430, mpi_comm_world, ierr)
1414 elseif (rank == to_proc)
then
1415 call mpi_recv(to_val, 1, mpi_double_precision, from_proc, &
1416 208020430, mpi_comm_world, status, ierr)
1432 integer,
intent(in) :: from_val
1434 integer,
intent(out) :: to_val
1436 integer,
intent(in) :: from_proc
1438 integer,
intent(in) :: to_proc
1441 integer :: rank, ierr, status(MPI_STATUS_SIZE)
1444 if (from_proc == to_proc)
then
1445 if (rank == from_proc)
then
1449 if (rank == from_proc)
then
1450 call mpi_send(from_val, 1, mpi_integer, to_proc, &
1451 208020430, mpi_comm_world, ierr)
1453 elseif (rank == to_proc)
then
1454 call mpi_recv(to_val, 1, mpi_integer, from_proc, &
1455 208020430, mpi_comm_world, status, ierr)
1472 integer,
intent(in) :: val
1474 integer,
intent(out) :: val_sum
1479 call mpi_reduce(val, val_sum, 1, mpi_integer, mpi_sum, 0, &
1480 mpi_comm_world, ierr)
1495 integer,
intent(in) :: val
1497 integer,
intent(out) :: val_sum
1502 call mpi_allreduce(val, val_sum, 1, mpi_integer, mpi_sum, &
1503 mpi_comm_world, ierr)
1518 real(kind=dp),
intent(in) :: val(:)
1520 real(kind=dp),
intent(out) :: val_avg(:)
1525 call assert(915136121,
size(val) ==
size(val_avg))
1526 call mpi_reduce(val, val_avg,
size(val), mpi_double_precision, &
1527 mpi_sum, 0, mpi_comm_world, ierr)
1545 real(kind=dp),
intent(in) :: val(:,:)
1547 real(kind=dp),
intent(out) :: val_avg(:,:)
1552 call assert(131229046,
size(val,1) ==
size(val_avg,1))
1553 call assert(992122167,
size(val,2) ==
size(val_avg,2))
1554 call mpi_reduce(val, val_avg,
size(val), mpi_double_precision, &
1555 mpi_sum, 0, mpi_comm_world, ierr)
1573 real(kind=dp),
intent(in) :: val
1575 real(kind=dp),
intent(out) :: val_avg
1580 call mpi_allreduce(val, val_avg, 1, mpi_double_precision, mpi_sum, &
1581 mpi_comm_world, ierr)
1597 real(kind=dp),
intent(in) :: val(:)
1599 real(kind=dp),
intent(out) :: val_avg(:)
1604 call assert(948533359,
size(val) ==
size(val_avg))
1605 call mpi_allreduce(val, val_avg,
size(val), mpi_double_precision, &
1606 mpi_sum, mpi_comm_world, ierr)
1622 integer,
intent(in) :: val
1624 integer,
intent(out) :: val_min
1629 call mpi_allreduce(val, val_min, 1, mpi_integer, mpi_min, &
1630 mpi_comm_world, ierr)
1645 integer,
intent(in) :: val
1647 integer,
intent(out) :: val_max
1652 call mpi_allreduce(val, val_max, 1, mpi_integer, mpi_max, &
1653 mpi_comm_world, ierr)
1668 real(kind=dp),
intent(in) :: val
1670 real(kind=dp),
intent(out) :: val_min
1675 call mpi_allreduce(val, val_min, 1, mpi_double_precision, mpi_min, &
1676 mpi_comm_world, ierr)
1691 real(kind=dp),
intent(in) :: val
1693 real(kind=dp),
intent(out) :: val_max
1698 call mpi_allreduce(val, val_max, 1, mpi_double_precision, mpi_max, &
1699 mpi_comm_world, ierr)
1713 integer,
intent(in) :: val
1716 integer :: min_val, max_val
1720 if (min_val == max_val)
then
1737 real(kind=dp),
intent(in) :: val
1740 real(kind=dp) :: min_val, max_val
1744 if (min_val == max_val)
then
1761 integer,
intent(in) :: send(:)
1763 integer,
intent(out) :: recv(size(send))
1768 call mpi_alltoall(send, 1, mpi_integer, recv, 1, mpi_integer, &
1769 mpi_comm_world, ierr)
1784 integer,
intent(in) :: send(:)
1786 integer,
intent(out) :: recv(:,:)
1789 integer :: n_proc, n_bin, n_data, ierr
1790 integer,
allocatable :: send_buf(:), recv_buf(:)
1793 n_data =
size(send, 1)
1794 call assert(353005542, all(shape(recv) == (/n_data, n_proc/)))
1797 allocate(send_buf(n_data))
1798 allocate(recv_buf(n_data * n_proc))
1800 call mpi_allgather(send_buf, n_data, mpi_integer, &
1801 recv_buf, n_data, mpi_integer, mpi_comm_world, ierr)
1803 recv = reshape(recv_buf, (/n_data, n_proc/))
1804 deallocate(send_buf)
1805 deallocate(recv_buf)
1819 real(kind=dp),
intent(in) :: send(:)
1821 real(kind=dp),
intent(out) :: recv(:,:)
1824 integer :: n_proc, n_bin, n_data, ierr
1825 real(kind=dp),
allocatable :: send_buf(:), recv_buf(:)
1828 n_data =
size(send, 1)
1829 call assert(291000580, all(shape(recv) == (/n_data, n_proc/)))
1832 allocate(send_buf(n_data))
1833 allocate(recv_buf(n_data * n_proc))
1835 call mpi_allgather(send_buf, n_data, mpi_double_precision, &
1836 recv_buf, n_data, mpi_double_precision, mpi_comm_world, ierr)
1838 recv = reshape(recv_buf, (/n_data, n_proc/))
1839 deallocate(send_buf)
1840 deallocate(recv_buf)
Interface for to_string functions.
Wrapper functions for MPI.
subroutine camp_mpi_init()
Initialize MPI.
subroutine camp_mpi_pack_integer_array(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
integer function camp_mpi_rank(comm)
Returns the rank of the current process.
subroutine camp_mpi_pack_real(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_allreduce_min_integer(val, val_min)
Computes the minimum of val across all processes, storing the result in val_min on all processes.
subroutine camp_mpi_pack_real_array(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_unpack_complex(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
logical function camp_mpi_support()
Whether MPI support is compiled in.
subroutine camp_mpi_bcast_packed(val, comm)
Broadcast the given value from process 0 to all other processes.
subroutine camp_mpi_reduce_avg_real_array_2d(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process.
subroutine camp_mpi_unpack_real_array_2d(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_pack_real_array_2d(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_pack_string_array(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_test()
Perform basic sanity checks on send/receive.
subroutine camp_mpi_unpack_integer_array(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_pack_logical(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_pack_complex(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
subroutine camp_mpi_unpack_integer(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_allgather_integer_array(send, recv)
Does an allgather of integer arrays (must be the same size on all processes).
subroutine camp_mpi_bcast_string(val, comm)
Broadcast the given value from process 0 to all other processes.
subroutine camp_mpi_unpack_logical(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
logical function camp_mpi_allequal_integer(val)
Returns whether all processors have the same value.
subroutine camp_mpi_reduce_sum_integer(val, val_sum)
Computes the sum of val across all processes, storing the result in val_sum on the root process.
subroutine camp_mpi_finalize()
Shut down MPI.
subroutine camp_mpi_bcast_integer(val, comm)
Broadcast the given value from process 0 to all other processes.
subroutine camp_mpi_abort(status)
Abort the program.
integer function camp_mpi_pack_size_real_array(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_transfer_integer(from_val, to_val, from_proc, to_proc)
Transfer the value between the given processes.
subroutine camp_mpi_reduce_avg_real_array(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process.
integer function camp_mpi_pack_size_integer_array(val, comm)
Determines the number of bytes required to pack the given value.
integer function camp_mpi_pack_size_logical(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_allreduce_max_real(val, val_max)
Computes the maximum of val across all processes, storing the result in val_max on all processes.
subroutine camp_mpi_reduce_avg_real(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on the root process.
subroutine camp_mpi_unpack_string_array(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
integer function camp_mpi_pack_size_complex(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_allreduce_average_real_array(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on all processes.
subroutine camp_mpi_allreduce_max_integer(val, val_max)
Computes the maximum of val across all processes, storing the result in val_max on all processes.
subroutine camp_mpi_barrier(comm)
Synchronize all processes.
subroutine camp_mpi_pack_integer(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
integer function camp_mpi_pack_size_string_array(val, comm)
Determines the number of bytes required to pack the given value.
integer function camp_mpi_pack_size_integer(val, comm)
Determines the number of bytes required to pack the given value.
integer function camp_mpi_size(comm)
Returns the total number of processes.
subroutine camp_mpi_allreduce_average_real(val, val_avg)
Computes the average of val across all processes, storing the result in val_avg on all processes.
subroutine camp_mpi_unpack_string(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_alltoall_integer(send, recv)
Does an all-to-all transfer of integers.
subroutine camp_mpi_unpack_real(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_allreduce_min_real(val, val_min)
Computes the minimum of val across all processes, storing the result in val_min on all processes.
subroutine camp_mpi_check_ierr(ierr)
Dies if ierr is not ok.
subroutine camp_mpi_transfer_real(from_val, to_val, from_proc, to_proc)
Transfer the value between the given processes.
integer function camp_mpi_pack_size_real(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_allgather_real_array(send, recv)
Does an allgather of real arrays (must be the same size on all processes).
logical function camp_mpi_allequal_real(val)
Returns whether all processors have the same value.
subroutine camp_mpi_unpack_real_array(buffer, position, val, comm)
Unpacks the given value from the buffer, advancing position.
subroutine camp_mpi_allreduce_sum_integer(val, val_sum)
Computes the sum of val across all processes, storing the result in val_sum on all processes.
integer function camp_mpi_pack_size_real_array_2d(val, comm)
Determines the number of bytes required to pack the given value.
integer function camp_mpi_pack_size_string(val, comm)
Determines the number of bytes required to pack the given value.
subroutine camp_mpi_pack_string(buffer, position, val, comm)
Packs the given value into the buffer, advancing position.
Common utility subroutines.
subroutine assert(code, condition_ok)
Errors unless condition_ok is true.
character(len=camp_util_convert_string_len) function logical_to_string(val)
Convert a logical to a string format.
subroutine die(code)
Error immediately.
subroutine assert_msg(code, condition_ok, error_msg)
Errors unless condition_ok is true.
character(len=camp_util_convert_string_len) function complex_to_string(val)
Convert a complex to a string format.
character(len=camp_util_convert_string_len) function integer_to_string(val)
Convert an integer to a string format.