LIST DATA
2026年5月26日 (火) 04:19時点におけるHirano (トーク | 投稿記録)による版 (ページの作成:「== Introduction == The list_data_module defined in list_data.F contains an extendable LIST_DATA struct that is used by linked_list_struct and Dicti…」)
Introduction
The list_data_module defined in list_data.F contains an extendable LIST_DATA struct that is used by linked_list_struct and dictionary_struct.
Module structure
The module structure is shown below. Note that while new variables and new procedures can be added, the existing "key" and "val" and procedure "equal" shouldn't by renamed or removed. Otherwise the linked_list_struct and dictionary_struct may not work properly.
<source lang="fortran">
!! Module for data structure used by linked list and dictionary.
MODULE list_data_module
IMPLICIT NONE
!!! Struct for user defined data type. !!! For the destructors to work correctly, it can not !!! contain any pointer that needs to be deallocated later. TYPE LIST_DATA INTEGER :: key !!! Criterion for "==" operator, do not change it. REAL8 :: val !!! Has value "NaN" for NULL data, do not change it. !!----------------------------------------------- !! You may add something new here as needed. !! !!----------------------------------------------- CONTAINS GENERIC :: OPERATOR(==) => equal PROCEDURE :: equal !!! (other) RESULT(T/F) END TYPE LIST_DATA
CONTAINS
! Check if two given data are the same. ! The criterion is key. !
LOGICAL FUNCTION equal(self,other) IMPLICIT NONE CLASS(LIST_DATA),INTENT(IN) :: self TYPE(LIST_DATA),INTENT(IN) :: other
IF(self%key==other%key) THEN
equal = .TRUE.
ELSE
equal = .FALSE.
ENDIF
END FUNCTION
END MODULE list_data_module
</source>