26 real(rkind) ,
allocatable :: x(:)
27 integer(ikind) :: dim_x
28 integer(ikind) :: lbound
29 logical :: is_lin=.false.
30 logical :: is_log=.false.
31 logical :: is_equi=.false.
33 integer :: last_access
40 real(rkind) ,
allocatable :: f1d(:)
41 real(rkind) ,
allocatable :: f2d(:,:)
42 real(rkind) ,
allocatable :: f3d(:,:,:)
43 real(rkind) ,
allocatable :: f4d(:,:,:,:)
44 type (axes_t
) ,
allocatable :: axe(:)
45 logical :: exist_f1d=.false.
46 logical :: exist_f2d=.false.
47 logical :: exist_f3d=.false.
48 logical :: exist_f4d=.false.
49 logical :: is_lin=.false.
50 logical :: is_log=.false.
51 logical :: with_warning=.false.
52 character(len=skind) :: name=
""
53 integer :: interpol_function = 0
54 character(len=132) :: result_label=
""
55 character(len=132) :: result_unit=
""
56 character(len=132) :: state_label=
""
63 integer(ikind) :: ierr
64 character (len=128) :: cerr
72 module procedure new_grid_1d, &
76 end interface new_grid
78 public :: grid_t, axes_t
81 public :: data_error_t
91 subroutine new_grid_1d(grid,f,x)
93 real(rkind),
intent(in) :: f(:)
94 real(rkind),
intent(in),
optional :: x(:)
95 type(grid_t
),
intent(out):: grid
100 call
assert(.not.grid%exist_f1d,
"Error: grid%f1d is still allocated")
101 call
assert(.not.grid%exist_f2d,
"Error: grid%f2d is still allocated")
102 call
assert(.not.grid%exist_f3d,
"Error: grid%f3d is still allocated")
103 call
assert(.not.grid%exist_f4d,
"Error: grid%f4d is still allocated")
104 if(present(x)) optargs=optargs+1
105 if(optargs.eq.1)
then
106 call
assert(
size(f)==
size(x),
"Error: size(f)" //
size(f)//
" /= =size(x) "//
size(x))
108 call
assert(
size(x(:))>=2,
"not sorted x")
109 allocate(grid%axe(1))
110 allocate(grid%axe(1)%x(
size(x)))
111 grid%axe(1)%x(:) = x(:)
112 grid%axe(1)%dim_x =
size(x)
113 grid%axe(1)%allocated = .true.
115 allocate(grid%f1d(
size(f,1)))
117 grid%exist_f1d=.true.
118 end subroutine new_grid_1d
125 subroutine new_grid_2d(grid,f,x,y)
127 real(rkind),
intent(in) :: f(:,:)
128 real(rkind),
intent(in),
optional :: x(:)
129 real(rkind),
intent(in),
optional :: y(:)
130 type(grid_t
),
intent(out):: grid
135 call
assert(.not.grid%exist_f1d,
"Error: grid%f1d is still allocated")
136 call
assert(.not.grid%exist_f2d,
"Error: grid%f2d is still allocated")
137 call
assert(.not.grid%exist_f3d,
"Error: grid%f3d is still allocated")
138 call
assert(.not.grid%exist_f4d,
"Error: grid%f4d is still allocated")
139 if(present(x)) optargs=optargs+1
140 if(present(y)) optargs=optargs+1
141 if(optargs.eq.2)
then
142 call
assert(
size(f,1)==
size(x),
"Error: size(f,1)" //
size(f,1)//
' /= =size(x) '//
size(x))
143 call
assert(
size(f,2)==
size(y),
"Error: size(f,2)" //
size(f,2)//
' /= =size(y) '//
size(y))
146 call
assert(
size(x(:))>=2,
"not sorted x")
147 call
assert(
size(y(:))>=2,
"not sorted y")
148 allocate(grid%axe(2))
149 allocate(grid%axe(1)%x(
size(x)))
150 allocate(grid%axe(2)%x(
size(y)))
151 grid%axe(1)%x(:) = x(:)
152 grid%axe(2)%x(:) = y(:)
153 grid%axe(1)%dim_x =
size(x)
154 grid%axe(2)%dim_x =
size(y)
155 grid%axe(1)%allocated = .true.
156 grid%axe(2)%allocated = .true.
158 call
assert(optargs==0,
"Error: wrong number of optionl arguments for new_grid_2d")
160 allocate(grid%f2d(
size(f,1),
size(f,2)))
162 grid%exist_f2d=.true.
163 end subroutine new_grid_2d
170 subroutine new_grid_3d(grid,f,x,y,z)
172 real(rkind),
intent(in) :: f(:,:,:)
173 real(rkind),
intent(in),
optional :: x(:)
174 real(rkind),
intent(in),
optional :: y(:)
175 real(rkind),
intent(in),
optional :: z(:)
176 type(grid_t
),
intent(out):: grid
181 call
assert(.not.grid%exist_f1d,
"Error: grid%f1d is still allocated")
182 call
assert(.not.grid%exist_f2d,
"Error: grid%f2d is still allocated")
183 call
assert(.not.grid%exist_f3d,
"Error: grid%f3d is still allocated")
184 call
assert(.not.grid%exist_f4d,
"Error: grid%f4d is still allocated")
185 if(present(x)) optargs=optargs+1
186 if(present(y)) optargs=optargs+1
187 if(present(z)) optargs=optargs+1
188 if(optargs.eq.3)
then
189 call
assert(
size(f,1)==
size(x),
"Error: size(fx,1)" //
size(f,1)//
' /= =size(x) '//
size(x))
190 call
assert(
size(f,2)==
size(y),
"Error: size(fx,2)" //
size(f,2)//
' /= =size(y) '//
size(y))
191 call
assert(
size(f,3)==
size(z),
"Error: size(fx,3)" //
size(f,3)//
' /= =size(z) '//
size(z))
195 call
assert(
size(x(:))>=2,
"not sorted x")
196 call
assert(
size(y(:))>=2,
"not sorted y")
197 call
assert(
size(z(:))>=2,
"not sorted z")
198 allocate(grid%axe(3))
199 allocate(grid%axe(1)%x(
size(x)))
200 allocate(grid%axe(2)%x(
size(y)))
201 allocate(grid%axe(3)%x(
size(z)))
202 grid%axe(1)%x(:) = x(:)
203 grid%axe(2)%x(:) = y(:)
204 grid%axe(3)%x(:) = z(:)
205 grid%axe(1)%dim_x =
size(x)
206 grid%axe(2)%dim_x =
size(y)
207 grid%axe(3)%dim_x =
size(z)
208 grid%axe(1)%allocated = .true.
209 grid%axe(2)%allocated = .true.
210 grid%axe(3)%allocated = .true.
212 call
assert(optargs==0,
"Error: wrong number of optionl arguments for new_grid_3d")
214 allocate(grid%f3d(
size(f,1),
size(f,2),
size(f,3)))
215 grid%f3d(:,:,:)=f(:,:,:)
216 grid%exist_f3d=.true.
217 end subroutine new_grid_3d
224 subroutine new_grid_4d(grid,f,w,x,y,z)
226 real(rkind),
intent(in) :: f(:,:,:,:)
227 real(rkind),
intent(in),
optional :: w(:)
228 real(rkind),
intent(in),
optional :: x(:)
229 real(rkind),
intent(in),
optional :: y(:)
230 real(rkind),
intent(in),
optional :: z(:)
231 type(grid_t
),
intent(out):: grid
236 call
assert(.not.grid%exist_f1d,
"Error: grid%f1d is still allocated")
237 call
assert(.not.grid%exist_f2d,
"Error: grid%f2d is still allocated")
238 call
assert(.not.grid%exist_f3d,
"Error: grid%f3d is still allocated")
239 call
assert(.not.grid%exist_f4d,
"Error: grid%f4d is still allocated")
240 if(present(w)) optargs=optargs+1
241 if(present(x)) optargs=optargs+1
242 if(present(y)) optargs=optargs+1
243 if(present(z)) optargs=optargs+1
244 if(optargs.eq.4)
then
245 call
assert(
size(f,1)==
size(w),
"Error: size(fx,1)" //
size(f,1)//
' /= =size(w) '//
size(w))
246 call
assert(
size(f,2)==
size(x),
"Error: size(fx,2)" //
size(f,2)//
' /= =size(x) '//
size(x))
247 call
assert(
size(f,3)==
size(y),
"Error: size(fx,3)" //
size(f,3)//
' /= =size(y) '//
size(y))
248 call
assert(
size(f,4)==
size(z),
"Error: size(fx,4)" //
size(f,4)//
' /= =size(z) '//
size(z))
253 call
assert(
size(w(:))>=2,
"not sorted w")
254 call
assert(
size(x(:))>=2,
"not sorted x")
255 call
assert(
size(y(:))>=2,
"not sorted y")
256 call
assert(
size(z(:))>=2,
"not sorted z")
257 allocate(grid%axe(4))
258 allocate(grid%axe(1)%x(
size(w)))
259 allocate(grid%axe(2)%x(
size(x)))
260 allocate(grid%axe(3)%x(
size(y)))
261 allocate(grid%axe(4)%x(
size(z)))
262 grid%axe(1)%x(:) = w(:)
263 grid%axe(2)%x(:) = x(:)
264 grid%axe(3)%x(:) = y(:)
265 grid%axe(4)%x(:) = z(:)
266 grid%axe(1)%dim_x =
size(w)
267 grid%axe(2)%dim_x =
size(x)
268 grid%axe(3)%dim_x =
size(y)
269 grid%axe(4)%dim_x =
size(z)
270 grid%axe(1)%allocated = .true.
271 grid%axe(2)%allocated = .true.
272 grid%axe(3)%allocated = .true.
273 grid%axe(4)%allocated = .true.
275 call
assert(optargs==0,
"Error: wrong number of optionl arguments for new_grid_4d")
277 allocate(grid%f4d(
size(f,1),
size(f,2),
size(f,3),
size(f,4)))
278 grid%f4d(:,:,:,:)=f(:,:,:,:)
279 grid%exist_f4d=.true.
280 end subroutine new_grid_4d
290 type(grid_t
),
intent(inout):: grid
292 if(
allocated(grid%f1d))
then
294 grid%exist_f1d=.false.
296 if(
allocated(grid%f2d))
then
298 grid%exist_f2d=.false.
300 if(
allocated(grid%f3d))
then
302 grid%exist_f3d=.false.
304 if(
allocated(grid%f4d))
then
306 grid%exist_f4d=.false.
308 if(
allocated(grid%axe))
then
340 subroutine interpol(w,x,y,z,fd1,fd2,fd3,fd4,grid,data_error)
343 real (rkind),
target ,
intent(in) :: w(:)
344 real (rkind),
target,
optional ,
intent(in) :: x(:)
345 real (rkind),
target,
optional ,
intent(in) :: y(:)
346 real (rkind),
target,
optional ,
intent(in) :: z(:)
347 real (rkind),
optional ,
intent(out):: fd1(:)
348 real (rkind),
optional ,
intent(out):: fd2(:,:)
349 real (rkind),
optional ,
intent(out):: fd3(:,:,:)
350 real (rkind),
optional ,
intent(out):: fd4(:,:,:,:)
351 type (grid_t
) ,
intent(inout):: grid
352 type (data_error_t
),
intent(out):: data_error
356 real (rkind) :: dw(size(w))
357 integer :: iw(size(w))
358 integer :: iw_sort(size(w))
359 real (rkind),
target :: w_s(size(w))
360 real (rkind),
pointer :: w_p(:)
362 real (rkind),
allocatable :: dx(:)
363 integer ,
allocatable :: ix(:)
364 integer ,
allocatable :: ix_sort(:)
365 real (rkind),
allocatable,
target :: x_s(:)
366 real (rkind),
pointer :: x_p(:)
368 real (rkind),
allocatable :: dy(:)
369 integer ,
allocatable :: iy(:)
370 integer,
allocatable :: iy_sort(:)
371 real (rkind),
allocatable,
target :: y_s(:)
372 real (rkind),
pointer :: y_p(:)
374 real (rkind),
allocatable :: dz(:)
375 integer ,
allocatable :: iz(:)
376 integer ,
allocatable :: iz_sort(:)
377 real (rkind),
allocatable,
target :: z_s(:)
378 real (rkind),
pointer :: z_p(:)
388 logical :: is_sorted_w = .false.
389 logical :: is_sorted_x = .false.
390 logical :: is_sorted_y = .false.
391 logical :: is_sorted_z = .false.
410 three_d =present(fd3)
414 call
assert(grid%exist_f1d .or. grid%exist_f2d .or.grid%exist_f3d.or.grid%exist_f4d, &
415 "Data not allocated for interpolation")
418 call
assert(one_d.and. .not.(two_d.or.three_d.or.four_d), &
419 "Type mismatch, only one f vector type possible!!")
420 if(with_x) call
assert(
size(x)==
size(w),
"Size w:"//
size(w)// &
421 "/= Size x:"//
size(x))
422 if(with_y) call
assert(
size(y)==
size(w),
"Size w:"//
size(w)// &
423 "/= Size y:"//
size(y))
424 if(with_z) call
assert(
size(z)==
size(w),
"Size w:"//
size(x)// &
425 "/= Size z:"//
size(z))
429 call
assert(with_x.and..not.(with_y.or.with_z),
"expect x present, y and z not present")
432 call
assert(with_y .and. .not. with_z,
"expect x and y present and z not present")
435 call
assert(with_y .and. with_z,
"expect x y and zvec present")
438 select case(grid%interpol_function)
443 allocate(dx(
size(x)),ix(
size(x)),ix_sort(
size(x)),x_s(
size(x)))
446 allocate(dy(
size(y)),iy(
size(y)),iy_sort(
size(y)),y_s(
size(y)))
449 allocate(dz(
size(z)),iz(
size(z)),iz_sort(
size(z)),z_s(
size(z)))
453 if(with_x)is_sorted_x=
sorted(x(:))
454 if(with_y)is_sorted_y=
sorted(y(:))
455 if(with_z)is_sorted_z=
sorted(z(:))
460 if(.not.is_sorted_w)
then
461 iw_sort(:)= (/ (
i,
i=1,
size(iw_sort(:)) ) /)
462 call
mrgrnk(w(:),iw_sort(:))
465 if(grid%axe(1)%is_log) w_p = log10(w_p)
467 if(grid%axe(1)%is_log)
then
476 if(.not.is_sorted_x)
then
477 ix_sort(:)= (/ (
i,
i=1,
size(ix_sort(:)) ) /)
478 call
mrgrnk(x(:),ix_sort(:))
481 if(grid%axe(2)%is_log) x_p = log10(x_p)
483 if(grid%axe(2)%is_log)
then
493 if(.not.is_sorted_y)
then
494 iy_sort(:)= (/ (
i,
i=1,
size(iy_sort(:)) ) /)
495 call
mrgrnk(y(:),iy_sort(:))
498 if(grid%axe(3)%is_log) y_p = log10(y_p)
500 if(grid%axe(3)%is_log)
then
510 if(.not.is_sorted_z)
then
511 iz_sort(:)= (/ (
i,
i=1,
size(iz_sort(:)) ) /)
512 call
mrgrnk(z(:),iz_sort(:))
515 if(grid%axe(4)%is_log) z_p = log10(z_p)
518 if(grid%axe(4)%is_log)
then
529 call interpol_index(w_p(:),grid%axe(1)%x(:),iw(:),dw(:),grid)
533 if(.not. is_sorted_w)
then
541 call interpol_index(x_p(:),grid%axe(2)%x(:),ix(:),dx(:),grid)
542 if(.not. is_sorted_x)
then
549 call interpol_index(y_p(:),grid%axe(3)%x(:),iy(:),dy(:),grid)
550 if(.not. is_sorted_y)
then
557 call interpol_index(z_p(:),grid%axe(4)%x(:),iz(:),dz(:),grid)
558 if(.not. is_sorted_z)
then
568 call interpo_4_1(iw(:),ix(:),iy(:),iz(:),dw(:),dx(:),dy(:),dz(:),fd1(:),grid)
570 call interpo_4_4(iw(:),ix(:),iy(:),iz(:),dw(:),dx(:),dy(:),dz(:),fd4(:,:,:,:),grid)
574 call interpo_3_1(iw(:),ix(:),iy(:),dw(:),dx(:),dy(:),fd1(:),grid)
576 call interpo_3_3(iw(:),ix(:),iy(:),dw(:),dx(:),dy(:),fd3(:,:,:),grid)
580 call interpo_2_1(iw(:),ix(:),dw(:),dx(:),fd1(:),grid)
582 call interpo_2_2(iw(:),ix(:),dw(:),dx(:),fd2(:,:),grid)
585 call interpo_1_1(iw(:),dw(:),fd1(:),grid)
589 deallocate(dx,ix,ix_sort,x_s)
592 deallocate(dy,iy,iy_sort,y_s)
595 deallocate(dz,iz,iz_sort,z_s)
599 if(one_d) fd1 = 10.0_rkind ** fd1
600 if(two_d) fd2 = 10.0_rkind ** fd2
601 if(three_d) fd3 = 10.0_rkind ** fd3
602 if(four_d) fd4 = 10.0_rkind ** fd4
607 call
assert(.not.(with_x.or.with_y.or.with_z),
"nuclear data '1001' must be a function of 1 parameter")
608 call
assert(grid%exist_f2d,
"nuclear data '1001' requires 2d table of data")
609 call
assert(one_d,
"nuclear data '1001' expected to be passed an effective 1d array")
614 call
assert(.not.(with_x.or.with_y.or.with_z),
"nuclear data '1002' must be a function of 1 parameter")
615 call
assert(grid%exist_f2d,
"nuclear data '1002' requires 2d table of data")
616 call
assert(one_d,
"nuclear data '1002' expected to be passed an effective 1d array")
621 call
assert(.not.(with_x.or.with_y.or.with_z),
"resonant charge data '1003' must be a function of 1 parameter")
622 call
assert(grid%exist_f1d,
"resonant charge transfer data '1003' requires 1d table of data")
623 call
assert(one_d,
"resonant charge transfer '1003' expected to be passed an effective 1d array")
624 call
rct_data_1003(grid%f1d, w, fd1, grid%with_warning, fun_err)
628 call
assert(.not.(with_y.or.with_z),
"sputter data '1004' must be a function of 2 parameters")
629 call
assert(grid%exist_f2d,
"sputter yield '1004' requires 2d table of data")
630 call
assert(one_d,
"sputter yield '1004' expected to be passed an 2d array")
635 call
assert(.not.(with_y.or.with_z),
"reflection yield '1005' must be a function of 2 parameters")
636 call
assert(grid%exist_f2d,
"reflection yield '1005' requires 2d table of data")
637 call
assert(one_d,
"reflection yield '1005' expected to be passed an 2d array")
642 call
assert(.not.(with_x.or.with_y.or.with_z),
"nuclear data '1006' must be a function of 1 parameter")
643 call
assert(grid%exist_f2d,
"nuclear data '1006' requires 2d table of data")
644 call
assert(one_d,
"nuclear data '1006' expected to be passed an effective 1d array")
648 write(*,*)
'Case for grid%interpol_function = ', grid%interpol_function,
' not yet coded'
652 if(fun_err%ierr.ne.0)
then
653 data_error%ierr = fun_err%ierr
654 data_error%cerr = fun_err%cerr
665 real(rkind),
intent (in) :: x(:)
684 subroutine interpol_index(x, axe, ix, dx, grid)
686 real(rkind) ,
intent(in) :: x(:)
687 real(rkind) ,
intent(out):: axe(:)
688 real(rkind) ,
intent(out):: dx(:)
689 integer(ikind),
intent(out):: ix(:)
690 type(grid_t
) ,
intent(in) :: grid
693 real(rkind) :: dx_help(size(dx))
694 integer(ikind):: ix_lb,ix_ub
701 call bound_check(axe(:), x(:),ix(:),dx(:),ix_lb,ix_ub, grid)
703 if(ix_lb>ix_ub)
return
705 call locate(axe, x(ix_lb),ix(ix_lb),dx(ix_lb))
706 call hunt(axe, x(ix_lb+1:ix_ub),ix(ix_lb+1:ix_ub),dx(ix_lb+1:ix_ub))
711 end subroutine interpol_index
717 subroutine bound_check(axe, x, ix, dx, lb, ub, grid)
719 real(rkind) ,
intent(in) :: axe(:)
720 real(rkind) ,
intent(in) :: x(:)
721 real(rkind) ,
intent(out):: dx(:)
722 integer(ikind),
intent(out):: ix(:)
723 integer(ikind),
intent(out):: lb, ub
724 type(grid_t
) ,
intent(in) :: grid
733 if(x(
i)>=axe(1))
then
738 dx(
i)=(x(
i)-axe(1))/(axe(2)-axe(1))
739 if(grid%with_warning) call
warning(.false.,
"Warning "// x(
i) &
740 //
" < "// axe(1)//
'in grid: ?')
747 if(x(
i)<=axe(
size(axe)))
then
752 dx(
i)=(x(
i)-axe(
size(axe)-1))/(axe(
size(axe))-axe(
size(axe)-1))
753 if(grid%with_warning) call
warning(.false.,
" Point "// x(
i) &
754 //
" out of bound in grid ")
758 end subroutine bound_check
764 subroutine interpo_1_1(ix,dx,fgrid1,grid)
766 integer(ikind),
intent(in) :: ix(:)
767 real(rkind),
intent(out):: fgrid1(:)
768 real(rkind),
intent(in) :: dx(:)
769 type(grid_t
),
intent(in) :: grid
776 if(ix(
i)<lbound(grid%f1d,1)) ii1=lbound(grid%f1d,1)
777 if(ix(
i)>ubound(grid%f1d,1)) ii1=ubound(grid%f1d,1)-1
780 fgrid1(
i)=grid%f1d(ii1) &
782 -grid%f1d(ii1))*dx(
i)
784 end subroutine interpo_1_1
791 subroutine interpo_2_1(ix,iy,dx,dy,fgrid1,grid)
793 integer(ikind),
intent(in) :: ix(:)
794 integer(ikind),
intent(in) :: iy(:)
795 real(rkind),
intent(out):: fgrid1(:)
796 real(rkind),
intent(in) :: dx(:)
797 real(rkind),
intent(in) :: dy(:)
798 type(grid_t
),
intent(in) :: grid
800 real(rkind)::f1, f2, f3
802 integer :: ii1, ii2, jj1, jj2
806 if(ii1<lbound(grid%f2d,1)) ii1=lbound(grid%f2d,1)
807 if(ii1>=ubound(grid%f2d,1)) ii1=ubound(grid%f2d,1)-1
810 if(jj1<lbound(grid%f2d,2)) jj1=lbound(grid%f2d,2)
811 if(jj1>=ubound(grid%f2d,2)) jj1=ubound(grid%f2d,2)-1
814 if(ii1.lt.1.or.ii2.gt.ubound(grid%f2d,1))
then
815 write(*,*)
'Error: ii1, ii2 = ', ii1, ii2
817 if(jj1.lt.1.or.jj2.gt.ubound(grid%f2d,2))
then
818 write(*,*)
'Error: jj1, jj2 = ', jj1, jj2
820 f1=grid%f2d(ii1,jj1) &
821 +(grid%f2d(ii2,jj1) &
822 -grid%f2d(ii1,jj1))*dx(
i)
823 f2=grid%f2d(ii1,jj2) &
824 +(grid%f2d(ii2,jj2) &
825 -grid%f2d(ii1,jj2))*dx(
i)
826 fgrid1(
i)=f1+(f2-f1)*dy(
i)
828 end subroutine interpo_2_1
834 subroutine interpo_2_2(ix,iy,dx,dy,fgrid2,grid)
836 integer(ikind),
intent(in) :: ix(:)
837 integer(ikind),
intent(in) :: iy(:)
838 real(rkind),
intent(out):: fgrid2(:,:)
839 real(rkind),
intent(in) :: dx(:)
840 real(rkind),
intent(in) :: dy(:)
841 type(grid_t
),
intent(in) :: grid
845 integer :: ii1, ii2, jj1, jj2
849 if(jj1<lbound(grid%f2d,2)) jj1=lbound(grid%f2d,2)
850 if(jj1>ubound(grid%f2d,2)) jj1=ubound(grid%f2d,2)-1
854 if(ii1<lbound(grid%f2d,1)) ii1=lbound(grid%f2d,1)
855 if(ii1>ubound(grid%f2d,1)) ii1=ubound(grid%f2d,1)-1
857 f1=grid%f2d(ii1,jj1) &
858 +(grid%f2d(ii2,jj1) &
859 -grid%f2d(ii1,jj1))*dx(
i)
860 f2=grid%f2d(ii1,jj2) &
861 +(grid%f2d(ii2,jj2) &
862 -grid%f2d(ii1,jj2))*dx(
i)
863 fgrid2(
i,j)=f1+(f2-f1)*dy(j)
866 end subroutine interpo_2_2
872 subroutine interpo_3_1(ix,iy,iz,dx,dy,dz,fgrid1,grid)
874 integer(ikind),
intent(in) :: ix(:)
875 integer(ikind),
intent(in) :: iy(:)
876 integer(ikind),
intent(in) :: iz(:)
877 real(rkind),
intent(out):: fgrid1(:)
878 real(rkind),
intent(in) :: dx(:)
879 real(rkind),
intent(in) :: dy(:)
880 real(rkind),
intent(in) :: dz(:)
881 type(grid_t
),
intent(in) :: grid
883 real(rkind)::f1, f2, f3, f4
885 integer :: ii1, ii2, jj1, jj2, kk1, kk2
889 if(ii1<lbound(grid%f3d,1)) ii1=lbound(grid%f3d,1)
890 if(ii1>ubound(grid%f3d,1)) ii1=ubound(grid%f3d,1)-1
893 if(jj1<lbound(grid%f3d,2)) jj1=lbound(grid%f3d,2)
894 if(jj1>ubound(grid%f3d,2)) jj1=ubound(grid%f3d,2)-1
897 if(kk1<lbound(grid%f3d,3)) kk1=lbound(grid%f3d,3)
898 if(kk1>ubound(grid%f3d,3)) kk1=ubound(grid%f3d,3)-1
900 f1=grid%f3d(ii1,jj1,kk1) &
901 +(grid%f3d(ii2,jj1,kk1) &
902 -grid%f3d(ii1,jj1,kk1))*dx(
i)
903 f2=grid%f3d(ii1,jj2,kk1) &
904 +(grid%f3d(ii2,jj2,kk1) &
905 -grid%f3d(ii1,jj2,kk1))*dx(
i)
907 f1=grid%f3d(ii1,jj1,kk2) &
908 +(grid%f3d(ii2,jj1,kk2) &
909 -grid%f3d(ii1,jj1,kk2))*dx(
i)
910 f2=grid%f3d(ii1,jj2,kk2) &
911 +(grid%f3d(ii2,jj2,kk2) &
912 -grid%f3d(ii1,jj2,kk2))*dx(
i)
914 fgrid1(
i)=f3+(f4-f3)*dz(
i)
916 end subroutine interpo_3_1
922 subroutine interpo_3_3(ix,iy,iz,dx,dy,dz,fgrid3,grid)
924 integer(ikind),
intent(in) :: ix(:)
925 integer(ikind),
intent(in) :: iy(:)
926 integer(ikind),
intent(in) :: iz(:)
927 real(rkind),
intent(out):: fgrid3(:,:,:)
928 real(rkind),
intent(in) :: dx(:)
929 real(rkind),
intent(in) :: dy(:)
930 real(rkind),
intent(in) :: dz(:)
931 type(grid_t
),
intent(in) :: grid
933 real(rkind)::f1, f2, f3, f4
935 integer :: ii1, ii2, jj1, jj2, kk1, kk2
939 if(kk1<lbound(grid%f3d,3)) kk1=lbound(grid%f3d,3)
940 if(kk1>ubound(grid%f3d,3)) kk1=ubound(grid%f3d,3)-1
944 if(jj1<lbound(grid%f3d,2)) jj1=lbound(grid%f3d,2)
945 if(jj1>ubound(grid%f3d,2)) jj1=ubound(grid%f3d,2)-1
949 if(ii1<lbound(grid%f3d,1)) ii1=lbound(grid%f3d,1)
950 if(ii1>ubound(grid%f3d,1)) ii1=ubound(grid%f3d,1)-1
952 f1=grid%f3d(ii1,jj1,kk1)&
953 +(grid%f3d(ii2,jj1,kk1) &
954 -grid%f3d(ii1,jj1,kk1))*dx(
i)
955 f2=grid%f3d(ii1,jj2,kk1) &
956 +(grid%f3d(ii2,jj2,kk1) &
957 -grid%f3d(ii1,jj2,kk1))*dx(
i)
959 f1=grid%f3d(ii1,jj1,kk2) &
960 +(grid%f3d(ii2,jj1,kk2) &
961 -grid%f3d(ii1,jj1,kk2))*dx(
i)
962 f2=grid%f3d(ii1,jj2,kk2) &
963 +(grid%f3d(ii2,jj2,kk2) &
964 -grid%f3d(ii1,jj2,kk2))*dx(
i)
966 fgrid3(
i,j,k)=f3+(f4-f3)*dz(k)
970 end subroutine interpo_3_3
976 subroutine interpo_4_1(iw,ix,iy,iz,dw,dx,dy,dz,fgrid1,grid)
978 integer(ikind),
intent(in) :: iw(:)
979 integer(ikind),
intent(in) :: ix(:)
980 integer(ikind),
intent(in) :: iy(:)
981 integer(ikind),
intent(in) :: iz(:)
982 real(rkind),
intent(out):: fgrid1(:)
983 real(rkind),
intent(in) :: dw(:)
984 real(rkind),
intent(in) :: dx(:)
985 real(rkind),
intent(in) :: dy(:)
986 real(rkind),
intent(in) :: dz(:)
987 type(grid_t
),
intent(in) :: grid
989 real(rkind)::f1, f2, f3, f4, f5, f6
991 integer :: ll1,ll2,ii1,ii2,jj1,jj2,kk1,kk2
995 if(ll1<lbound(grid%f4d,1)) ll1=lbound(grid%f4d,1)
996 if(ll1>ubound(grid%f4d,1)) ll1=ubound(grid%f4d,1)-1
999 if(ii1<lbound(grid%f4d,2)) ii1=lbound(grid%f4d,2)
1000 if(ii1>ubound(grid%f4d,2)) ii1=ubound(grid%f4d,2)-1
1003 if(jj1<lbound(grid%f4d,3)) jj1=lbound(grid%f4d,3)
1004 if(jj1>ubound(grid%f4d,3)) jj1=ubound(grid%f4d,3)-1
1007 if(kk1<lbound(grid%f4d,4)) kk1=lbound(grid%f4d,4)
1008 if(kk1>ubound(grid%f4d,4)) kk1=ubound(grid%f4d,4)-1
1011 f1=grid%f4d(ll1,ii1,jj1,kk1) &
1012 +(grid%f4d(ll2,ii1,jj1,kk1) &
1013 -grid%f4d(ll1,ii1,jj1,kk1))*dw(
i)
1014 f2=grid%f4d(ll1,ii2,jj1,kk1) &
1015 +(grid%f4d(ll2,ii2,jj1,kk1) &
1016 -grid%f4d(ll1,ii2,jj1,kk1))*dw(
i)
1018 f1=grid%f4d(ll1,ii1,jj2,kk1) &
1019 +(grid%f4d(ll2,ii1,jj2,kk1) &
1020 -grid%f4d(ll1,ii1,jj2,kk1))*dw(
i)
1021 f2=grid%f4d(ll1,ii2,jj2,kk1) &
1022 +(grid%f4d(ll2,ii2,jj2,kk1) &
1023 -grid%f4d(ll1,ii2,jj2,kk1))*dw(
i)
1029 f1=grid%f4d(ll1,ii1,jj1,kk2) &
1030 +(grid%f4d(ll2,ii1,jj1,kk2) &
1031 -grid%f4d(ll1,ii1,jj1,kk2))*dw(
i)
1032 f2=grid%f4d(ll1,ii2,jj1,kk2) &
1033 +(grid%f4d(ll2,ii2,jj1,kk2) &
1034 -grid%f4d(ll1,ii2,jj1,kk2))*dw(
i)
1036 f1=grid%f4d(ll1,ii1,jj2,kk2) &
1037 +(grid%f4d(ll2,ii1,jj2,kk2) &
1038 -grid%f4d(ll1,ii1,jj2,kk2))*dw(
i)
1039 f2=grid%f4d(ll1,ii2,jj2,kk2) &
1040 +(grid%f4d(ll2,ii2,jj2,kk2) &
1041 -grid%f4d(ll1,ii2,jj2,kk2))*dw(
i)
1046 fgrid1(
i)=f5+(f6-f5)*dz(
i)
1050 end subroutine interpo_4_1
1057 subroutine interpo_4_4(iw,ix,iy,iz,dw,dx,dy,dz,fgrid1,grid)
1059 integer(ikind),
intent(in) :: iw(:)
1060 integer(ikind),
intent(in) :: ix(:)
1061 integer(ikind),
intent(in) :: iy(:)
1062 integer(ikind),
intent(in) :: iz(:)
1063 real(rkind),
intent(out):: fgrid1(:,:,:,:)
1064 real(rkind),
intent(in) :: dw(:)
1065 real(rkind),
intent(in) :: dx(:)
1066 real(rkind),
intent(in) :: dy(:)
1067 real(rkind),
intent(in) :: dz(:)
1068 type(grid_t
),
intent(in) :: grid
1070 real(rkind)::f1, f2, f3, f4, f5, f6
1072 integer :: ll1,ll2,ii1,ii2,jj1,jj2,kk1,kk2
1076 if(kk1<lbound(grid%f4d,4)) kk1=lbound(grid%f4d,4)
1077 if(kk1>ubound(grid%f4d,4)) kk1=ubound(grid%f4d,4)-1
1081 if(jj1<lbound(grid%f4d,3)) jj1=lbound(grid%f4d,3)
1082 if(jj1>ubound(grid%f4d,3)) jj1=ubound(grid%f4d,3)-1
1086 if(ii1<lbound(grid%f4d,2)) ii1=lbound(grid%f4d,2)
1087 if(ii1>ubound(grid%f4d,2)) ii1=ubound(grid%f4d,2)-1
1091 if(ll1<lbound(grid%f4d,1)) ll1=lbound(grid%f4d,1)
1092 if(ll1>ubound(grid%f4d,1)) ll1=ubound(grid%f4d,1)-1
1095 f1=grid%f4d(ll1,ii1,jj1,kk1) &
1096 +(grid%f4d(ll2,ii1,jj1,kk1) &
1097 -grid%f4d(ll1,ii1,jj1,kk1))*dw(l)
1098 f2=grid%f4d(ll1,ii2,jj1,kk1) &
1099 +(grid%f4d(ll2,ii2,jj1,kk1) &
1100 -grid%f4d(ll1,ii2,jj1,kk1))*dw(l)
1102 f1=grid%f4d(ll1,ii1,jj2,kk1) &
1103 +(grid%f4d(ll2,ii1,jj2,kk1) &
1104 -grid%f4d(ll1,ii1,jj2,kk1))*dw(l)
1105 f2=grid%f4d(ll1,ii2,jj2,kk1) &
1106 +(grid%f4d(ll2,ii2,jj2,kk1) &
1107 -grid%f4d(ll1,ii2,jj2,kk1))*dw(l)
1113 f1=grid%f4d(ll1,ii1,jj1,kk2) &
1114 +(grid%f4d(ll2,ii1,jj1,kk2) &
1115 -grid%f4d(ll1,ii1,jj1,kk2))*dw(l)
1116 f2=grid%f4d(ll1,ii2,jj1,kk2) &
1117 +(grid%f4d(ll2,ii2,jj1,kk2) &
1118 -grid%f4d(ll1,ii2,jj1,kk2))*dw(l)
1120 f1=grid%f4d(ll1,ii1,jj2,kk2) &
1121 +(grid%f4d(ll2,ii1,jj2,kk2) &
1122 -grid%f4d(ll1,ii1,jj2,kk2))*dw(l)
1123 f2=grid%f4d(ll1,ii2,jj2,kk2) &
1124 +(grid%f4d(ll2,ii2,jj2,kk2) &
1125 -grid%f4d(ll1,ii2,jj2,kk2))*dw(l)
1130 fgrid1(l,
i,j,k)=f5+(f6-f5)*dz(
i)
1137 end subroutine interpo_4_4
1144 subroutine hunt(axe,x,ix,dx)
1156 real(rkind) ,
intent(inout) :: axe(:)
1157 real(rkind),
intent(in) :: x(:)
1158 real(rkind),
intent(out) :: dx(:)
1159 integer(ikind),
intent(out) :: ix(:)
1160 integer(ikind),
save :: last_access=1
1162 integer :: lbnd, ubnd
1165 lbnd=lbound(axe(:),1)
1166 ubnd=ubound(axe(:),1)
1170 call hunt_nrv(axe(:), x(:), ix(:), last_access)
1176 dx(
i)=(x(
i)-axe(ix(
i)))/(axe(ix(
i)+1)-axe(ix(
i)))
1192 subroutine hunt_nrv(xx,x,ix,jlo)
1200 real(rkind),
intent(in) :: xx(:)
1201 real(rkind),
intent(in) :: x(:)
1202 integer(ikind),
intent(out) :: ix(:)
1203 integer(ikind),
intent(inout) :: jlo
1205 integer :: n,inc,jhi,jm
1213 ascnd = (xx(n) >= xx(1))
1217 if (jlo <= 0 .or. jlo > n)
then
1224 if (x(
i) >= xx(jlo) .eqv. ascnd)
then
1231 if (x(
i) < xx(jhi) .eqv. ascnd)
exit
1244 if (x(
i) >= xx(jlo) .eqv. ascnd)
exit
1252 if (jhi-jlo <= 1)
then
1253 if (x(
i) == xx(n)) jlo=n-1
1254 if (x(
i) == xx(1)) jlo=1
1258 if (x(
i) >= xx(jm) .eqv. ascnd)
then
1267 end subroutine hunt_nrv
1277 subroutine locate(axe, x, ix, dx)
1284 real(rkind),
intent(inout) :: axe(:)
1285 real(rkind),
intent(in) :: x
1286 real(rkind),
intent(out) :: dx
1287 integer(ikind),
intent(out) :: ix
1289 integer :: lbnd, ubnd
1292 lbnd=lbound(axe(:),1)
1293 ubnd=ubound(axe(:),1)
1296 ix=locate_nrv(axe(:),x)
1301 dx=(x-axe(ix))/(axe(ix+1)-axe(ix))
1309 end subroutine locate
1317 function locate_nrv(xx,x) result (result)
1323 real(rkind),
intent(in) :: xx(:)
1324 real(rkind),
intent(in) :: x
1327 integer :: n,jl,jm,ju
1333 ascnd = (xx(n) >= xx(1))
1337 if (ju-jl <= 1)
exit
1340 if (ascnd .eqv. (x >= xx(jm)))
then
1346 if (x == xx(1))
then
1348 else if (x == xx(n))
then
1354 end function locate_nrv
subroutine reflect_data_1005(function_parameters, energy_arr, angle_arr, refl_arr, with_warnings, fun_err)
AMNS External function ...
utils module from Silvio Gori's grid package
subroutine nuclear_data_1001(function_parameters, x, f, with_warnings, fun_err)
AMNS External function ...
subroutine, public interpol(w, x, y, z, fd1, fd2, fd3, fd4, grid, data_error)
interpolate in the grid
subroutine sputter_data_1004(function_parameters, energy_arr, angle_arr, yield_arr, with_warnings, fun_err)
AMNS External function ...
subroutine nuclear_data_1002(function_parameters, Tin, f, with_warnings, fun_err)
AMNS External function ...
unit_h module from Silvio Gori's grid package
strings module from Silvio Gori's grid package
subroutine rct_data_1003(function_parameters, Tin, f, with_warnings, fun_err)
AMNS External function ...
if error_status np ndarray[np.double_t, ndim=2] np ndarray[np.double_t, ndim=2] np ndarray[np.double_t, ndim=2] ndim
subroutine, public warning(lcond, message)
subroutine, public delete(grid)
deallocate a grid
subroutine nuclear_data_1006(function_parameters, x, f, with_warnings, fun_err)
logical function sorted(x)
return true if the passed array is sorted
f90_kind module from Silvio Gori's grid package
subroutine, public set_option(grid, warning)
set the "with_warning" flag in grid to the value of "warning"
subroutine, public assert(lcond, message)