HASTY Morton (Z-order) key class.
!< HASTY Morton (Z-order) **key** class. module hasty_key_morton !----------------------------------------------------------------------------------------------------------------------------------- !< HASTY Morton (Z-order) **key** class. !----------------------------------------------------------------------------------------------------------------------------------- use hasty_key_base use penf !----------------------------------------------------------------------------------------------------------------------------------- !----------------------------------------------------------------------------------------------------------------------------------- implicit none private public :: key_morton !----------------------------------------------------------------------------------------------------------------------------------- !----------------------------------------------------------------------------------------------------------------------------------- type, extends(key_base) :: key_morton !< Morton (Z-order) **key** class to identify a node. integer(I8P) :: key=0_I8P !< The key. contains ! public deferred methods procedure, pass(self) :: destroy !< Destroy the key. procedure, pass(self) :: stringify !< Return a string representation of the key. ! private deferred methods procedure, pass(lhs), private :: is_equal !< Implement `==` operator. endtype key_morton !----------------------------------------------------------------------------------------------------------------------------------- contains ! public deferred methods elemental subroutine destroy(self) !--------------------------------------------------------------------------------------------------------------------------------- !< Destroy the key. !--------------------------------------------------------------------------------------------------------------------------------- class(key_morton), intent(inout) :: self !< The key. !--------------------------------------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------------------------------------- ! there is no dynamic memory, nothing to destroy self%key = 0_I8P !--------------------------------------------------------------------------------------------------------------------------------- endsubroutine destroy pure function stringify(self) result(str_key) !--------------------------------------------------------------------------------------------------------------------------------- !< Return a string representation of the key. !--------------------------------------------------------------------------------------------------------------------------------- class(key_morton), intent(in) :: self !< The key. character(len=:), allocatable :: str_key !< The key stringified. !--------------------------------------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------------------------------------- str_key = trim(str(self%key)) !--------------------------------------------------------------------------------------------------------------------------------- endfunction stringify ! private deferred methods elemental logical function is_equal(lhs, rhs) !--------------------------------------------------------------------------------------------------------------------------------- !< Implement `==` operator. !--------------------------------------------------------------------------------------------------------------------------------- class(key_morton), intent(in) :: lhs !< Left hand side. class(*), intent(in) :: rhs !< Rigth hand side. !--------------------------------------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------------------------------------- is_equal = .false. select type(rhs) type is(key_morton) is_equal = lhs%key==rhs%key endselect !--------------------------------------------------------------------------------------------------------------------------------- endfunction is_equal endmodule hasty_key_morton