15 integer, intent(inout), dimension(:) :: array
16 integer, intent(in) :: arraySize
17 type(GlobalCellType), dimension(:), pointer :: idxToGlobal
18 logical(LGP) :: z_only
19
20 integer :: QSORT_THRESHOLD = 8
21 include "qsort_inline.inc"
22
23 contains
26
27
28
29 function lessthan(n, m)
result(isLess)
30 integer(I4B), intent(in) :: n
31 integer(I4B), intent(in) :: m
32 logical(LGP) :: isLess
33
34 real(DP), dimension(3) :: xyz_n, xyz_m
35
36
39
40
41 if (.not. is_close(xyz_n(3), xyz_m(3), 10 * epsilon(xyz_n(3)))) then
42 isless = xyz_n(3) > xyz_m(3)
43 else if (.not. is_close(xyz_n(2), xyz_m(2), 10 * epsilon(xyz_n(2)))) then
44 isless = xyz_n(2) > xyz_m(2)
45 else if (.not. is_close(xyz_n(1), xyz_m(1), 10 * epsilon(xyz_n(1)))) then
46 isless = xyz_n(1) < xyz_m(1)
47 else
48 isless = .false.
49 end if
50
52
53
54
56 type(GlobalCellType) :: gc
57 logical(LGP) :: use_only_z
58 real(DP), dimension(3) :: global_xyz
59
60 real(DP) :: x, y, z
61 real(DP) :: xc, yc, xo, yo, angrot
62
63 z = dhalf * (gc%v_model%dis_top%get(gc%index) + &
64 gc%v_model%dis_bot%get(gc%index))
65
66 x = dzero
67 y = dzero
68 if (.not. use_only_z) then
69 xc = gc%v_model%dis_xc%get(gc%index)
70 yc = gc%v_model%dis_yc%get(gc%index)
71 xo = gc%v_model%dis_xorigin%get()
72 yo = gc%v_model%dis_yorigin%get()
73 angrot = gc%v_model%dis_angrot%get()
74 call dis_transform_xy(xc, yc, xo, yo, angrot, x, y)
75 end if
76
77 global_xyz = [x, y, z]
78
80
81
83 integer, intent(in) :: a, b
84 integer :: hold
85
86 hold = array(a)
87 array(a) = array(b)
88 array(b) = hold
89
91
92
93 subroutine rshift(left, right)
94 integer, intent(in) :: left, right
95 integer :: hold
96
97 hold = array(right)
98 array(left + 1:right) = array(left:right - 1)
99 array(left) = hold
100
real(dp) function, dimension(3) get_global_xyz(gc, use_only_z)
Utility function to convert global cell.
logical(lgp) function lessthan(n, m)
subroutine rshift(left, right)