|
1 | 1 | ! Copyright (c), The Regents of the University of California |
2 | 2 | ! Terms of use are as specified in LICENSE.txt |
| 3 | + |
3 | 4 | module occupancy_m |
4 | 5 | use iso_fortran_env, only : int64 |
| 6 | + use tensor_m, only : tensor_t |
5 | 7 | implicit none |
6 | 8 |
|
7 | 9 | private |
8 | 10 | public :: occupancy_t |
| 11 | + public :: phase_space_bin_t |
| 12 | + |
| 13 | + integer, parameter :: default_kind = kind(1) |
| 14 | + |
| 15 | + type phase_space_bin_t |
| 16 | + integer, allocatable :: loc(:) |
| 17 | + end type |
| 18 | + |
| 19 | + interface phase_space_bin_t |
| 20 | + |
| 21 | + pure module function construct_phase_space_bin(tensor, minima, maxima, bins_per_dimension) result(phase_space_bin) |
| 22 | + implicit none |
| 23 | + type(tensor_t), intent(in) :: tensor |
| 24 | + real, intent(in) :: minima(:), maxima(:) |
| 25 | + integer, intent(in) :: bins_per_dimension |
| 26 | + type(phase_space_bin_t) phase_space_bin |
| 27 | + end function |
| 28 | + |
| 29 | + end interface |
| 30 | + |
| 31 | + type occupancy_t |
| 32 | + !! Encapsulate the occupancy status of phase-space bins |
| 33 | + private |
| 34 | + type(phase_space_bin_t), allocatable :: phase_space_bin_(:) |
| 35 | + real, allocatable :: minima_(:), maxima_(:) |
| 36 | + integer bins_per_dimension_, num_occupied_ |
| 37 | + contains |
| 38 | + procedure, non_overridable :: occupied |
| 39 | + procedure, non_overridable :: add |
| 40 | + procedure, non_overridable :: num_occupied |
| 41 | + procedure, non_overridable :: num_bins |
| 42 | + end type |
| 43 | + |
| 44 | + interface occupancy_t |
| 45 | + |
| 46 | + module pure function construct_occupancy(minima, maxima, bins_per_dimension) result(occupancy) |
| 47 | + implicit none |
| 48 | + real, intent(in) :: minima(:), maxima(:) |
| 49 | + integer, intent(in) :: bins_per_dimension |
| 50 | + type(occupancy_t) occupancy |
| 51 | + end function |
| 52 | + |
| 53 | + end interface |
| 54 | + |
| 55 | + interface |
| 56 | + |
| 57 | + module subroutine add(self, bin) |
| 58 | + !! Add bin to list of occupied bins |
| 59 | + implicit none |
| 60 | + class(occupancy_t), intent(inout) :: self |
| 61 | + type(phase_space_bin_t), intent(in) :: bin |
| 62 | + end subroutine |
| 63 | + |
| 64 | + pure module function occupied(self, bin) result(bin_occupied) |
| 65 | + !! Result is true if the provided bin location has been occupied |
| 66 | + implicit none |
| 67 | + class(occupancy_t), intent(in) :: self |
| 68 | + type(phase_space_bin_t), intent(in) :: bin |
| 69 | + logical bin_occupied |
| 70 | + end function |
| 71 | + |
| 72 | + pure module function num_occupied(self) result(occupied) |
| 73 | + !! Result is the number of occupied bins |
| 74 | + implicit none |
| 75 | + class(occupancy_t), intent(in) :: self |
| 76 | + integer occupied |
| 77 | + end function |
| 78 | + |
| 79 | + pure module function num_bins(self) result(bins) |
| 80 | + !! Result is the total number of bins |
| 81 | + implicit none |
| 82 | + class(occupancy_t), intent(in) :: self |
| 83 | + integer(int64) bins |
| 84 | + end function |
9 | 85 |
|
10 | | - type occupancy_t |
11 | | - private |
12 | | - logical, allocatable :: occupied_1D_(:) |
13 | | - logical, allocatable :: occupied_2D_(:,:) |
14 | | - logical, allocatable :: occupied_3D_(:,:,:) |
15 | | - logical, allocatable :: occupied_4D_(:,:,:,:) |
16 | | - logical, allocatable :: occupied_5D_(:,:,:,:,:) |
17 | | - logical, allocatable :: occupied_6D_(:,:,:,:,:,:) |
18 | | - logical, allocatable :: occupied_7D_(:,:,:,:,:,:,:) |
19 | | - logical, allocatable :: occupied_8D_(:,:,:,:,:,:,:,:) |
20 | | - logical, allocatable :: occupied_9D_(:,:,:,:,:,:,:,:,:) |
21 | | - logical, allocatable :: occupied_10D_(:,:,:,:,:,:,:,:,:,:) |
22 | | - logical, allocatable :: occupied_11D_(:,:,:,:,:,:,:,:,:,:,:) |
23 | | - logical, allocatable :: occupied_12D_(:,:,:,:,:,:,:,:,:,:,:,:) |
24 | | - logical, allocatable :: occupied_13D_(:,:,:,:,:,:,:,:,:,:,:,:,:) |
25 | | - logical, allocatable :: occupied_14D_(:,:,:,:,:,:,:,:,:,:,:,:,:,:) |
26 | | - logical, allocatable :: occupied_15D_(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) |
27 | | - contains |
28 | | - procedure, non_overridable :: vacate |
29 | | - procedure, non_overridable :: occupy |
30 | | - procedure, non_overridable :: occupied |
31 | | - procedure, non_overridable :: num_occupied |
32 | | - procedure, non_overridable :: num_bins |
33 | | - procedure, non_overridable :: allocated_dim |
34 | | - end type |
35 | | - |
36 | | - interface |
37 | | - |
38 | | - pure module subroutine vacate(self, dims) |
39 | | - implicit none |
40 | | - class(occupancy_t), intent(inout) :: self |
41 | | - integer, intent(in) :: dims(:) |
42 | | - end subroutine |
43 | | - |
44 | | - pure module subroutine occupy(self, loc) |
45 | | - implicit none |
46 | | - class(occupancy_t), intent(inout) :: self |
47 | | - integer, intent(in) :: loc(:) |
48 | | - end subroutine |
49 | | - |
50 | | - pure module function occupied(self, loc) result(bin_occupied) |
51 | | - implicit none |
52 | | - class(occupancy_t), intent(in) :: self |
53 | | - integer, intent(in) :: loc(:) |
54 | | - logical bin_occupied |
55 | | - end function |
56 | | - |
57 | | - pure module function num_occupied(self) result(bins_occupied) |
58 | | - implicit none |
59 | | - class(occupancy_t), intent(in) :: self |
60 | | - integer(int64) bins_occupied |
61 | | - end function |
62 | | - |
63 | | - pure module function num_bins(self) result(bins_total) |
64 | | - implicit none |
65 | | - class(occupancy_t), intent(in) :: self |
66 | | - integer(int64) bins_total |
67 | | - end function |
68 | | - |
69 | | - pure module function allocated_dim(self) result(my_dim) |
70 | | - implicit none |
71 | | - class(occupancy_t), intent(in) :: self |
72 | | - integer my_dim |
73 | | - end function |
74 | | - |
75 | | - end interface |
| 86 | + end interface |
76 | 87 |
|
77 | 88 | end module occupancy_m |
0 commit comments