Skip to content

Commit

Permalink
Mostly cosmetic changes and annotation of library file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Jackson committed Jan 15, 2025
1 parent d9e93b8 commit d42e5f9
Show file tree
Hide file tree
Showing 5 changed files with 429 additions and 323 deletions.
65 changes: 33 additions & 32 deletions src/comms.F90
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ module w90_comms
!public :: comms_send ! send data from one node to another
public :: mpirank
public :: mpisize
public :: comms_sync_err
public :: valid_communicator ! test if communicator is initialised
public :: comms_sync_error
public :: valid_communicator
!! test whether communicator is initialised; returns true always for serial build

! versions without error synchronisation, use at own risk
public :: comms_no_sync_allreduce ! reduce data onto all nodes
Expand Down Expand Up @@ -258,7 +259,7 @@ integer function mpisize(comm)
end function

! synchronise error condition between MPI processess
subroutine comms_sync_err(comm, error, ierr)
subroutine comms_sync_error(comm, error, ierr)
implicit none
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(inout) :: error
Expand All @@ -270,7 +271,7 @@ subroutine comms_sync_err(comm, error, ierr)
! you could check mpiierr here, but truly all bets are off in that case
if (abserr > 0 .and. ierr == 0) call recv_error(error)
#endif
end subroutine comms_sync_err
end subroutine comms_sync_error

subroutine comms_array_split(numpoints, counts, displs, comm)
!! Given an array of size numpoints, we want to split on num_nodes nodes. This function returns
Expand Down Expand Up @@ -1441,7 +1442,7 @@ subroutine comms_barrier(error, comm)
type(w90_error_type), allocatable, intent(out) :: error
type(w90_comm_type), intent(in) :: comm

call comms_sync_err(comm, error, 0)
call comms_sync_error(comm, error, 0)
if (allocated(error)) return
! The barrier is almost redundant since the sync is global, unless DISABLE_ERROR_SYNC defined
call comms_no_sync_barrier(comm)
Expand All @@ -1456,7 +1457,7 @@ subroutine comms_bcast_int(array, size, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0)
call comms_sync_error(comm, error, 0)
if (allocated(error)) return

call comms_no_sync_bcast_int(array, size, error, comm)
Expand All @@ -1471,7 +1472,7 @@ subroutine comms_bcast_real(array, size, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_bcast_real(array, size, error, comm)
Expand All @@ -1486,7 +1487,7 @@ subroutine comms_bcast_logical(array, size, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_bcast_logical(array, size, error, comm)
Expand All @@ -1501,7 +1502,7 @@ subroutine comms_bcast_char(array, size, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_bcast_char(array, size, error, comm)
Expand All @@ -1517,7 +1518,7 @@ subroutine comms_bcast_cmplx(array, size, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_bcast_cmplx(array, size, error, comm)
Expand All @@ -1533,7 +1534,7 @@ subroutine comms_reduce_int(array, size, op, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_reduce_int(array, size, op, error, comm)
Expand All @@ -1550,7 +1551,7 @@ subroutine comms_reduce_real(array, size, op, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_reduce_real(array, size, op, error, comm)
Expand All @@ -1567,7 +1568,7 @@ subroutine comms_reduce_cmplx(array, size, op, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_reduce_cmplx(array, size, op, error, comm)
Expand All @@ -1584,7 +1585,7 @@ subroutine comms_allreduce_real(array, size, op, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_allreduce_real(array, size, op, error, comm)
Expand All @@ -1600,7 +1601,7 @@ subroutine comms_allreduce_cmplx(array, size, op, error, comm)
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_allreduce_cmplx(array, size, op, error, comm)
Expand All @@ -1618,7 +1619,7 @@ subroutine comms_gatherv_real_1(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_real_1(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1637,7 +1638,7 @@ subroutine comms_gatherv_real_2(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_real_2(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1656,7 +1657,7 @@ subroutine comms_gatherv_real_3(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_real_3(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1675,7 +1676,7 @@ subroutine comms_gatherv_real_2_3(array, localcount, rootglobalarray, counts, di
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_real_2_3(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1700,7 +1701,7 @@ subroutine comms_gatherv_cmplx_1(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_cmplx_1(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1719,7 +1720,7 @@ subroutine comms_gatherv_cmplx_2(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_cmplx_2(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1738,7 +1739,7 @@ subroutine comms_gatherv_cmplx_3(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_cmplx_3(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1757,7 +1758,7 @@ subroutine comms_gatherv_cmplx_3_4(array, localcount, rootglobalarray, counts, d
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_cmplx_3_4(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1776,7 +1777,7 @@ subroutine comms_gatherv_cmplx_4(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_cmplx_4(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1795,7 +1796,7 @@ subroutine comms_gatherv_logical(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_gatherv_logical(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1814,7 +1815,7 @@ subroutine comms_scatterv_real_1(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_real_1(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1833,7 +1834,7 @@ subroutine comms_scatterv_real_2(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_real_2(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1852,7 +1853,7 @@ subroutine comms_scatterv_real_3(array, localcount, rootglobalarray, counts, dis
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_real_3(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1871,7 +1872,7 @@ subroutine comms_scatterv_cmplx_4(array, localcount, rootglobalarray, counts, di
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_cmplx_4(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1890,7 +1891,7 @@ subroutine comms_scatterv_int_1(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_int_1(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1910,7 +1911,7 @@ subroutine comms_scatterv_int_2(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_int_2(array, localcount, rootglobalarray, counts, displs, &
Expand All @@ -1930,7 +1931,7 @@ subroutine comms_scatterv_int_3(array, localcount, rootglobalarray, counts, disp
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error

call comms_sync_err(comm, error, 0) ! sync error state across comm
call comms_sync_error(comm, error, 0) ! sync error state across comm
if (allocated(error)) return

call comms_no_sync_scatterv_int_3(array, localcount, rootglobalarray, counts, displs, &
Expand Down
16 changes: 8 additions & 8 deletions src/error.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ subroutine set_error_fatal(err, mesg, comm)
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_fatal)
call comms_sync_err(comm, err, code_fatal)
call comms_sync_error(comm, err, code_fatal)
end subroutine set_error_fatal

subroutine set_error_alloc(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_alloc)
call comms_sync_err(comm, err, code_alloc)
call comms_sync_error(comm, err, code_alloc)
end subroutine set_error_alloc

subroutine set_error_dealloc(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_dealloc)
call comms_sync_err(comm, err, code_dealloc)
call comms_sync_error(comm, err, code_dealloc)
end subroutine set_error_dealloc

! note, this is not used in comms routines
Expand All @@ -67,39 +67,39 @@ subroutine set_error_mpi(err, mesg, comm)
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_mpi)
call comms_sync_err(comm, err, code_mpi)
call comms_sync_error(comm, err, code_mpi)
end subroutine set_error_mpi

subroutine set_error_input(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_input)
call comms_sync_err(comm, err, code_input)
call comms_sync_error(comm, err, code_input)
end subroutine set_error_input

subroutine set_error_file(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_file)
call comms_sync_err(comm, err, code_file)
call comms_sync_error(comm, err, code_file)
end subroutine set_error_file

subroutine set_error_unconv(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_unconv)
call comms_sync_err(comm, err, code_unconv)
call comms_sync_error(comm, err, code_unconv)
end subroutine set_error_unconv

subroutine set_error_warn(err, mesg, comm)
type(w90_error_type), allocatable, intent(out) :: err
character(len=*), intent(in) :: mesg
type(w90_comm_type), intent(in) :: comm
call set_base_error(err, mesg, code_warning)
call comms_sync_err(comm, err, code_warning)
call comms_sync_error(comm, err, code_warning)
end subroutine set_error_warn

end module w90_error
Loading

0 comments on commit d42e5f9

Please sign in to comment.