Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. SUBROUTINE locate(xx,n,x,j)
  2. INTEGER, INTENT(out) :: j
  3. REAL*8 x,xx(n)
  4. INTEGER jl,jm,ju,n
  5. jl=0
  6. ju=n+1
  7.  
  8. 10 if(ju-jl.gt.1)then
  9. jm=(ju+jl)/2
  10. if((xx(n).ge.xx(1)).eqv.(x.ge.xx(jm)))then
  11. jl=jm
  12. else
  13. ju=jm
  14. endif
  15. goto 10
  16. endif
  17.  
  18. if(x.eq.xx(1))then
  19. j=1
  20. else if(x.eq.xx(n))then
  21. j=n-1
  22. else
  23. j=jl
  24. endif
  25. return
  26. END
  27.  
  28. function CDF_lambda(no_target, temp) result(lambda)
  29. implicit none
  30. integer(I2B), intent(in) :: no_target
  31. real(BW),intent(in) :: temp
  32. real(BW) :: rand, dy
  33. integer(I2B) :: jlo, N_interp_points, min_index, N_points_table, n1, n2
  34. real(BW), allocatable :: CDFtable(:)
  35.  
  36.  
  37. N_points_table= 1000
  38. N_interp_points=2 !2 for linear interpolation
  39. jlo=0
  40. CALL RANDOM_NUMBER(rand)
  41.  
  42. !first find the right two temperatures, then find the right rows, then interpolate
  43. n1=int((temp-100)/50)+1
  44. n2=n1+1
  45. allocate(CDFtable(N_points_table))
  46. ...
  47. !setting the content of CDFtable
  48. ...
  49. call locate(CDFtable,N_points_table,rand,jlo)
  50. ....
  51. ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement