Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SUBROUTINE locate(xx,n,x,j)
- INTEGER, INTENT(out) :: j
- REAL*8 x,xx(n)
- INTEGER jl,jm,ju,n
- jl=0
- ju=n+1
- 10 if(ju-jl.gt.1)then
- jm=(ju+jl)/2
- if((xx(n).ge.xx(1)).eqv.(x.ge.xx(jm)))then
- jl=jm
- else
- ju=jm
- endif
- goto 10
- endif
- if(x.eq.xx(1))then
- j=1
- else if(x.eq.xx(n))then
- j=n-1
- else
- j=jl
- endif
- return
- END
- function CDF_lambda(no_target, temp) result(lambda)
- implicit none
- integer(I2B), intent(in) :: no_target
- real(BW),intent(in) :: temp
- real(BW) :: rand, dy
- integer(I2B) :: jlo, N_interp_points, min_index, N_points_table, n1, n2
- real(BW), allocatable :: CDFtable(:)
- N_points_table= 1000
- N_interp_points=2 !2 for linear interpolation
- jlo=0
- CALL RANDOM_NUMBER(rand)
- !first find the right two temperatures, then find the right rows, then interpolate
- n1=int((temp-100)/50)+1
- n2=n1+1
- allocate(CDFtable(N_points_table))
- ...
- !setting the content of CDFtable
- ...
- call locate(CDFtable,N_points_table,rand,jlo)
- ....
- ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement