MOM6
mom_coms::efp_sum_across_pes Interface Reference

Detailed Description

Sum a value or 1-d array of values across processors, returning the sums in place.

Definition at line 64 of file MOM_coms.F90.

Private functions

subroutine efp_list_sum_across_pes (EFPs, nval, errors)
 This subroutine does a sum across PEs of a list of EFP variables, returning the sums in place, with all overflows carried. More...
 
subroutine efp_val_sum_across_pes (EFP, error)
 This subroutine does a sum across PEs of an EFP variable, returning the sums in place, with all overflows carried. More...
 

Detailed Description

Sum a value or 1-d array of values across processors, returning the sums in place.

Definition at line 64 of file MOM_coms.F90.

Functions and subroutines

◆ efp_list_sum_across_pes()

subroutine mom_coms::efp_sum_across_pes::efp_list_sum_across_pes ( type(efp_type), dimension(:), intent(inout)  EFPs,
integer, intent(in)  nval,
logical, dimension(:), intent(out), optional  errors 
)
private

This subroutine does a sum across PEs of a list of EFP variables, returning the sums in place, with all overflows carried.

Parameters
[in,out]efpsThe list of extended fixed point numbers
[in]nvalThe number of values being summed.
[out]errorsA list of error flags for each sum

Definition at line 788 of file MOM_coms.F90.

789  type(EFP_type), dimension(:), &
790  intent(inout) :: EFPs !< The list of extended fixed point numbers
791  !! being summed across PEs.
792  integer, intent(in) :: nval !< The number of values being summed.
793  logical, dimension(:), &
794  optional, intent(out) :: errors !< A list of error flags for each sum
795 
796  ! This subroutine does a sum across PEs of a list of EFP variables,
797  ! returning the sums in place, with all overflows carried.
798 
799  integer(kind=8), dimension(ni,nval) :: ints
800  integer(kind=8) :: prec_error
801  logical :: error_found
802  character(len=256) :: mesg
803  integer :: i, n
804 
805  if (num_pes() > max_count_prec) call mom_error(fatal, &
806  "reproducing_sum: Too many processors are being used for the value of "//&
807  "prec. Reduce prec to (2^63-1)/num_PEs.")
808 
809  prec_error = (2_8**62 + (2_8**62 - 1)) / num_pes()
810  ! overflow_error is an overflow error flag for the whole module.
811  overflow_error = .false. ; error_found = .false.
812 
813  do i=1,nval ; do n=1,ni ; ints(n,i) = efps(i)%v(n) ; enddo ; enddo
814 
815  call sum_across_pes(ints(:,:), ni*nval)
816 
817  if (present(errors)) errors(:) = .false.
818  do i=1,nval
819  overflow_error = .false.
820  call carry_overflow(ints(:,i), prec_error)
821  do n=1,ni ; efps(i)%v(n) = ints(n,i) ; enddo
822  if (present(errors)) errors(i) = overflow_error
823  if (overflow_error) then
824  write (mesg,'("EFP_list_sum_across_PEs error at ",i6," val was ",ES12.6, ", prec_error = ",ES12.6)') &
825  i, efp_to_real(efps(i)), real(prec_error)
826  call mom_error(warning, mesg)
827  endif
828  error_found = error_found .or. overflow_error
829  enddo
830  if (error_found .and. .not.(present(errors))) then
831  call mom_error(fatal, "Overflow in EFP_list_sum_across_PEs.")
832  endif
833 

◆ efp_val_sum_across_pes()

subroutine mom_coms::efp_sum_across_pes::efp_val_sum_across_pes ( type(efp_type), intent(inout)  EFP,
logical, intent(out), optional  error 
)
private

This subroutine does a sum across PEs of an EFP variable, returning the sums in place, with all overflows carried.

Parameters
[in,out]efpThe extended fixed point numbers being summed across PEs.
[out]errorAn error flag for this sum

Definition at line 838 of file MOM_coms.F90.

839  type(EFP_type), intent(inout) :: EFP !< The extended fixed point numbers
840  !! being summed across PEs.
841  logical, optional, intent(out) :: error !< An error flag for this sum
842 
843  ! This subroutine does a sum across PEs of a list of EFP variables,
844  ! returning the sums in place, with all overflows carried.
845 
846  integer(kind=8), dimension(ni) :: ints
847  integer(kind=8) :: prec_error
848  logical :: error_found
849  character(len=256) :: mesg
850  integer :: n
851 
852  if (num_pes() > max_count_prec) call mom_error(fatal, &
853  "reproducing_sum: Too many processors are being used for the value of "//&
854  "prec. Reduce prec to (2^63-1)/num_PEs.")
855 
856  prec_error = (2_8**62 + (2_8**62 - 1)) / num_pes()
857  ! overflow_error is an overflow error flag for the whole module.
858  overflow_error = .false. ; error_found = .false.
859 
860  do n=1,ni ; ints(n) = efp%v(n) ; enddo
861 
862  call sum_across_pes(ints(:), ni)
863 
864  if (present(error)) error = .false.
865 
866  overflow_error = .false.
867  call carry_overflow(ints(:), prec_error)
868  do n=1,ni ; efp%v(n) = ints(n) ; enddo
869  if (present(error)) error = overflow_error
870  if (overflow_error) then
871  write (mesg,'("EFP_val_sum_across_PEs error val was ",ES12.6, ", prec_error = ",ES12.6)') &
872  efp_to_real(efp), real(prec_error)
873  call mom_error(warning, mesg)
874  endif
875  error_found = error_found .or. overflow_error
876 
877  if (error_found .and. .not.(present(error))) then
878  call mom_error(fatal, "Overflow in EFP_val_sum_across_PEs.")
879  endif
880 

The documentation for this interface was generated from the following file: