Skip to content

Commit

Permalink
rename request_this_point -> request_live_point and point_needed -> l…
Browse files Browse the repository at this point in the history
…ive_point_needed + tidy comments
  • Loading branch information
AdamOrmondroyd committed Jan 9, 2024
1 parent 293c016 commit 494b62c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/polychord/generate.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ subroutine GenerateLivePoints(loglikelihood,prior,settings,RTI,mpi_information)
use array_module, only: add_point
use abort_module
#ifdef MPI
use mpi_module, only: mpi_bundle,is_root,linear_mode,throw_point,catch_point,more_points_needed,sum_integers,sum_doubles,request_point,no_more_points,request_this_point,point_needed
use mpi_module, only: mpi_bundle,is_root,linear_mode,throw_point,catch_point,more_points_needed,sum_integers,sum_doubles,request_point,no_more_points,request_live_point,live_point_needed
#else
use mpi_module, only: mpi_bundle,is_root,linear_mode
#endif
Expand Down Expand Up @@ -198,7 +198,7 @@ function prior(cube) result(theta)
! use the time as an ordering identifier, cheat by using the birth contour
live_point(settings%b0) = ngenerated
ngenerated = ngenerated+1
call request_this_point(live_point,mpi_information,worker_id)
call request_live_point(live_point,mpi_information,worker_id)
end do

do while(active_workers>0)
Expand Down Expand Up @@ -229,7 +229,7 @@ function prior(cube) result(theta)
! use the time as a unique identifier, cheat by using the birth contour
live_point(settings%b0) = ngenerated
ngenerated = ngenerated+1
call request_this_point(live_point,mpi_information,worker_id)
call request_live_point(live_point,mpi_information,worker_id)
else
call no_more_points(mpi_information,worker_id) ! Otherwise, send a signal to stop
active_workers=active_workers-1 ! decrease the active worker counter
Expand All @@ -248,7 +248,7 @@ function prior(cube) result(theta)

! The workers simply generate and send points until they're told to stop by the administrator

do while(point_needed(live_point,mpi_information))
do while(live_point_needed(live_point,mpi_information))
time0 = time()
call calculate_point( loglikelihood, prior, live_point, settings,nlike) ! Compute physical coordinates, likelihoods and derived parameters
ndiscarded=ndiscarded+1
Expand Down
36 changes: 18 additions & 18 deletions src/polychord/mpi_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -695,22 +695,22 @@ end function more_points_needed

!> Request specific live points
! administrator ----> worker
! request_this_point(live_point) point_needed -> true
! request_live_point(live_point) point_needed -> true
! no_more_points (defined above) point_needed -> false
!

!> Request this point
!> Request live point
!!
!! This subroutine is used by the root node to request a specific live point
subroutine request_this_point(live_point,mpi_information,worker_id)
subroutine request_live_point(live_point,mpi_information,worker_id)
implicit none
type(mpi_bundle), intent(in) :: mpi_information
integer, intent(in) :: worker_id !> Worker to request a new point from
real(dp), intent(in), dimension(:) :: live_point !> The live point to be sent


call MPI_SEND( &
live_point, &! not sending anything
call MPI_SEND( &!
live_point, &! live point being sent
size(live_point), &!
MPI_DOUBLE_PRECISION, &! sending doubles
worker_id, &! process id to send to
Expand All @@ -719,42 +719,42 @@ subroutine request_this_point(live_point,mpi_information,worker_id)
mpierror &! error flag
)

end subroutine request_this_point
end subroutine request_live_point

!> See if another point is needed
!!
!! This subroutine is used by the root node to request a specific live point
function point_needed(live_point,mpi_information)
function live_point_needed(live_point,mpi_information)
use abort_module
implicit none
type(mpi_bundle), intent(in) :: mpi_information
real(dp),intent(out),dimension(:) :: live_point !> live point to throw

integer, dimension(MPI_STATUS_SIZE) :: mpistatus ! status identifier

logical :: point_needed !> Whether we need more points or not
logical :: live_point_needed !> Whether we need more points or not

call MPI_RECV( &!
live_point, &!
live_point, &! live point recieved
size(live_point), &!
MPI_DOUBLE_PRECISION, &!
mpi_information%root, &!
MPI_ANY_TAG, &!
mpi_information%communicator,&!
mpistatus, &!
mpierror &!
MPI_DOUBLE_PRECISION, &! receiving doubles
mpi_information%root, &! root node
MPI_ANY_TAG, &! mpi tag
mpi_information%communicator,&! mpi handle
mpistatus, &! status identifier
mpierror &! error flag
)

! If we've recieved a kill signal, then exit this loop
if(mpistatus(MPI_TAG) == tag_gen_stop ) then
point_needed = .false.
live_point_needed = .false.
else if(mpistatus(MPI_TAG) == tag_gen_request) then
point_needed = .true.
live_point_needed = .true.
else
call halt_program('generate error: unrecognised tag')
end if

end function point_needed
end function live_point_needed


#endif
Expand Down

0 comments on commit 494b62c

Please sign in to comment.