Roberto Trotta
unread,Nov 21, 2008, 8:23:42 AM11/21/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to SuperBayeS Users
Hi
as a temporary quick-fix patch, I suggest the following:
in source/mcsamples.f90, replace the
function ConfidVal
with the code below. This will make sure the code does not get stuck
in an infinite loop (and will print out a warning in case the
convergence to the desired limit has not been attained).
I will fix this in a more sophisticated way in a future release with a
series of cumulative patches for smaller bugs like this that we have
found in the meantime.
Let me know if this helps,
Roberto
function ConfidVal(ix,limfrac,upper,ix1,ix2)
integer, intent(IN) :: ix
real, intent(IN) :: limfrac
logical, intent(IN) :: upper
integer, intent(IN), optional :: ix1,ix2
real ConfidVal, samps
real try, lasttry, try_t, try_b, try_t_prev, try_b_prev
integer l,t, jj
integer:: maxjj=1000
real*8, parameter :: tol = 1E-6, tolt=1.0
!find upper and lower bounds
jj =0
l=0
t=nrows-1
if (present(ix1)) l=ix1
if (present(ix2)) t = ix2
try_b = minval(coldata(ix,l:t))
try_t = maxval(coldata(ix,l:t))
samps = sum(coldata(1,l:t))
lasttry = -1
if (upper) then
do
try = sum(coldata(1,l:t),mask = coldata(ix,l:t) > (try_b +
try_t)/2)
if (try > samps*limfrac) then
try_b = (try_b+try_t)/2
else
try_t = (try_b+try_t)/2
end if
if (try == lasttry) exit
lasttry = try
end do
else
do
try = sum(coldata(1,l:t),mask = coldata(ix,l:t) < (try_b +
try_t)/2)
!write(*,'(A,E30.20)') 'Current mean value/target = ', try/
(samps*limfrac)
!write(*,'(A,E30.20)') 'This is for a mean = ', (try_b +
try_t)/2
if (try > samps*limfrac) then
try_t_prev = try_t
try_t = (try_b+try_t)/2
!write(*,'(A,E30.20)') 'Reducing try top = ', try_t
else
try_b_prev = try_b
try_b = (try_b+try_t)/2
if (try_b .eq. 0d0) then
try_b = try_b + 0.05*try_t
!write(*,*) 'Reset try_b to = ', try_b
end if
!write(*,'(A,E30.20)') 'Increasing try bot to = ', try_b
end if
!if ( (try == lasttry) .and. (abs(1 - try/(samps*limfrac))
< tol)) exit
!if ( (try == lasttry) .and. (abs(1 - try/(samps*limfrac))
> tol)) then
! write(*,*) 'sometjhing is rotten', (abs(1 - try/
(samps*limfrac)))
! write(*,*) 'latest: ', try_b, try_t
! write(*,*) 'previous: ', try_b_prev, try_t_prev
! stop
! exit
!end if
!if (abs(1 - try/(samps*limfrac)) < tol) then
! write(*,*) 'tolerance reacghed =', abs(1 - try/
(samps*limfrac))
! try_t = try
! exit
!end if
!write(*,*) jj, 'sometjhing is rotten? this has to go to
zero', (abs(1 - try/(samps*limfrac)))
!write(*,*) 'latest: ', try_b, try_t
!write(*,*) 'previous: ', try_b_prev, try_t_prev
!write(*,'(A,2E30.20)') '1E10*(try-last)%:', abs(1-try/
lasttry), tol
!write(*,'(A,2E30.20)') 'target :', abs(1 - try/
(samps*limfrac)), tolt
if (( abs(1-try/lasttry) < tol) .and. (abs(1 - try/
(samps*limfrac)) < tolt)) exit
lasttry = try
jj = jj+1
if(jj>maxjj) then
write(*,*) 'Warninng, could not converge to correct
limit! Continuing...'
exit
end if
end do
!write(*,*) 'DONE MINE LOWER JOB', try_t
!STOP
end if
ConfidVal = try_t
end function ConfidVal