2019-04-25 02:59:26 +08:00
|
|
|
!****h* root/fortran/test/vol_connector.F90
|
|
|
|
!
|
|
|
|
! NAME
|
|
|
|
! vol_connector.F90
|
|
|
|
!
|
|
|
|
! FUNCTION
|
|
|
|
!
|
|
|
|
! Tests basic Fortran VOL plugin operations (registration, etc.).
|
|
|
|
! Uses the null VOL connector (built with the testing code)
|
|
|
|
! which is loaded as a dynamic plugin.
|
|
|
|
!
|
|
|
|
! COPYRIGHT
|
|
|
|
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
! Copyright by The HDF Group. *
|
|
|
|
! All rights reserved. *
|
|
|
|
! *
|
|
|
|
! This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
! terms governing use, modification, and redistribution, is contained in *
|
2024-10-19 12:13:04 +08:00
|
|
|
! the LICENSE file, which can be found at the root of the source code *
|
2021-02-17 22:52:36 +08:00
|
|
|
! distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2019-04-25 02:59:26 +08:00
|
|
|
! If you do not have access to either file, you may request a copy from *
|
|
|
|
! help@hdfgroup.org. *
|
|
|
|
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
!
|
|
|
|
!*****
|
|
|
|
|
|
|
|
MODULE VOL_TMOD
|
|
|
|
|
|
|
|
USE HDF5
|
2019-06-14 22:48:27 +08:00
|
|
|
USE TH5_MISC
|
|
|
|
USE TH5_MISC_GEN
|
2019-04-25 02:59:26 +08:00
|
|
|
IMPLICIT NONE
|
|
|
|
|
2019-05-17 04:05:12 +08:00
|
|
|
INTEGER, PARAMETER :: NATIVE_VOL_CONNECTOR_VALUE = 0
|
2019-06-19 00:39:21 +08:00
|
|
|
CHARACTER(LEN=180) :: NATIVE_VOL_CONNECTOR_NAME
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
CONTAINS
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
! Function: test_registration_by_name()
|
|
|
|
!
|
|
|
|
! Purpose: Tests if we can load, register, and close a VOL
|
|
|
|
! connector by name.
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
|
|
|
|
SUBROUTINE test_registration_by_name(total_error)
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
|
|
|
INTEGER, INTENT(INOUT) :: total_error
|
|
|
|
INTEGER :: error = 0
|
|
|
|
|
|
|
|
LOGICAL :: is_registered = .FALSE.
|
|
|
|
INTEGER(hid_t) :: vol_id = 0, vol_id_out = 1
|
|
|
|
CHARACTER(LEN=64) :: name
|
2019-06-13 23:31:14 +08:00
|
|
|
CHARACTER(LEN=1) :: name_null
|
2019-04-25 02:59:26 +08:00
|
|
|
INTEGER(SIZE_T) :: name_len
|
2019-05-17 04:05:12 +08:00
|
|
|
INTEGER(hid_t) :: file_id
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
! The null VOL connector should not be registered at the start of the test
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
! Register the connector by name
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5VLregister_connector_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id, error)
|
2019-04-25 02:59:26 +08:00
|
|
|
CALL check("H5VLregister_connector_by_name_f",error,total_error)
|
2020-05-27 05:01:09 +08:00
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
! The connector should be registered now
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
CALL H5VLget_connector_id_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id_out, error)
|
|
|
|
CALL check("H5VLget_connector_id_by_name_f",error,total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error)
|
|
|
|
CALL check("H5F_create_f",error,total_error)
|
2019-04-25 04:17:10 +08:00
|
|
|
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5VLget_connector_name_f(file_id, name, error, name_len)
|
2019-04-25 04:17:10 +08:00
|
|
|
CALL check("H5VLget_connector_name_f",error,total_error)
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL VERIFY("H5VLget_connector_name_f", INT(name_len), LEN_TRIM(NATIVE_VOL_CONNECTOR_NAME), total_error)
|
2019-04-25 04:17:10 +08:00
|
|
|
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5VLget_connector_name_f(file_id, name, error)
|
|
|
|
CALL check("H5VLget_connector_name_f",error,total_error)
|
2019-06-19 00:39:21 +08:00
|
|
|
CALL VERIFY("H5VLget_connector_name_f", TRIM(name), NATIVE_VOL_CONNECTOR_NAME, total_error)
|
2019-04-25 04:17:10 +08:00
|
|
|
|
2019-06-13 23:31:14 +08:00
|
|
|
CALL H5VLget_connector_name_f(file_id, name_null, error, name_len)
|
|
|
|
CALL check("H5VLget_connector_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLget_connector_name_f", INT(name_len), LEN_TRIM(NATIVE_VOL_CONNECTOR_NAME), total_error)
|
|
|
|
|
|
|
|
CALL H5VLget_connector_name_f(file_id, name_null, error)
|
|
|
|
CALL check("H5VLget_connector_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLget_connector_name_f", name_null, NATIVE_VOL_CONNECTOR_NAME(1:1), total_error)
|
|
|
|
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5Fclose_f(file_id, error)
|
|
|
|
CALL check("H5Fclose_f",error,total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
CALL H5VLclose_f(vol_id_out, error)
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL check("H5VLclose_f",error, total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
END SUBROUTINE test_registration_by_name
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
! Function: test_registration_by_value()
|
|
|
|
!
|
|
|
|
! Purpose: Tests if we can load, register, and close a VOL
|
|
|
|
! connector by value.
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SUBROUTINE test_registration_by_value(total_error)
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
|
|
|
INTEGER, INTENT(INOUT) :: total_error
|
|
|
|
INTEGER :: error = 0
|
2020-01-29 08:18:38 +08:00
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
LOGICAL :: is_registered = .FALSE.
|
|
|
|
INTEGER(hid_t) :: vol_id = 0
|
|
|
|
|
|
|
|
|
|
|
|
! The null VOL connector should not be registered at the start of the test
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
! Register the connector by value
|
2019-05-17 04:05:12 +08:00
|
|
|
CALL H5VLregister_connector_by_value_f(NATIVE_VOL_CONNECTOR_VALUE, vol_id, error)
|
2019-04-25 02:59:26 +08:00
|
|
|
CALL check("H5VLregister_connector_by_value_f", error, total_error)
|
|
|
|
|
|
|
|
! The connector should be registered now
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error)
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
END SUBROUTINE test_registration_by_value
|
|
|
|
|
2019-05-23 03:09:17 +08:00
|
|
|
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
! Function: test_registration_by_name()
|
|
|
|
!
|
|
|
|
! Purpose: Tests if we can load, register, and close a VOL
|
|
|
|
! connector by name.
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
|
|
|
|
SUBROUTINE test_registration_by_fapl(total_error)
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
|
|
|
|
INTEGER, INTENT(INOUT) :: total_error
|
|
|
|
INTEGER :: error = 0
|
|
|
|
|
|
|
|
LOGICAL :: is_registered = .FALSE.
|
|
|
|
INTEGER(hid_t) :: vol_id = 0, vol_id_out = 1
|
|
|
|
INTEGER(hid_t) :: file_id
|
|
|
|
INTEGER(hid_t) :: fapl_id
|
|
|
|
TYPE(C_PTR) :: f_ptr
|
2024-10-04 03:19:33 +08:00
|
|
|
LOGICAL :: are_same = .FALSE.
|
2019-05-23 03:09:17 +08:00
|
|
|
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error)
|
2019-06-13 23:31:14 +08:00
|
|
|
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error)
|
2019-05-23 03:09:17 +08:00
|
|
|
|
|
|
|
! The null VOL connector should not be registered at the start of the test
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f( "FAKE_VOL_CONNECTOR_NAME", is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .FALSE., total_error)
|
2019-05-23 03:09:17 +08:00
|
|
|
|
|
|
|
CALL H5VLregister_connector_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id, error)
|
|
|
|
CALL check("H5VLregister_connector_by_name_f",error,total_error)
|
2020-05-27 05:01:09 +08:00
|
|
|
|
2019-05-23 03:09:17 +08:00
|
|
|
! The connector should be registered now
|
2020-01-29 08:18:38 +08:00
|
|
|
CALL H5VLis_connector_registered_by_name_f(NATIVE_VOL_CONNECTOR_NAME, is_registered, error)
|
|
|
|
CALL check("H5VLis_connector_registered_by_name_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLis_connector_registered_by_name_f", is_registered, .TRUE., total_error)
|
2019-05-23 03:09:17 +08:00
|
|
|
|
|
|
|
! Register the connector
|
|
|
|
CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl_id, error)
|
|
|
|
CALL check("H5Pcreate_f",error,total_error)
|
|
|
|
|
2019-06-19 00:39:21 +08:00
|
|
|
IF(TRIM(NATIVE_VOL_CONNECTOR_NAME) .EQ. "native")THEN
|
|
|
|
CALL H5Pset_vol_f(fapl_id, vol_id, error)
|
|
|
|
CALL check("H5Pset_vol_f",error,total_error)
|
2019-06-12 03:28:10 +08:00
|
|
|
|
2019-06-19 00:39:21 +08:00
|
|
|
CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error)
|
|
|
|
CALL check("H5Pget_vol_id_f",error,total_error)
|
2024-10-04 03:19:33 +08:00
|
|
|
CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
|
|
|
|
CALL check("H5VLcmp_connector_cls_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)
|
2019-05-23 03:09:17 +08:00
|
|
|
|
2019-06-19 00:39:21 +08:00
|
|
|
f_ptr = C_NULL_PTR
|
|
|
|
CALL H5Pset_vol_f(fapl_id, vol_id, error, f_ptr)
|
|
|
|
CALL check("H5Pset_vol_f",error,total_error)
|
2020-05-27 05:01:09 +08:00
|
|
|
|
2019-06-19 00:39:21 +08:00
|
|
|
CALL H5Pget_vol_id_f(fapl_id, vol_id_out, error)
|
|
|
|
CALL check("H5Pget_vol_id_f",error,total_error)
|
2024-10-04 03:19:33 +08:00
|
|
|
are_same = .FALSE.
|
|
|
|
CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
|
|
|
|
CALL check("H5VLcmp_connector_cls_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)
|
2019-06-19 00:39:21 +08:00
|
|
|
ENDIF
|
2019-06-12 03:28:10 +08:00
|
|
|
|
2020-01-17 05:29:34 +08:00
|
|
|
CALL H5VLget_connector_id_by_name_f(NATIVE_VOL_CONNECTOR_NAME, vol_id_out, error)
|
|
|
|
CALL check("H5VLget_connector_id_by_name_f",error,total_error)
|
2024-10-04 03:19:33 +08:00
|
|
|
are_same = .FALSE.
|
|
|
|
CALL H5VLcmp_connector_cls_f(are_same, vol_id, vol_id_out, error)
|
|
|
|
CALL check("H5VLcmp_connector_cls_f",error,total_error)
|
|
|
|
CALL VERIFY("H5VLcmp_connector_cls_f", are_same, .TRUE., total_error)
|
2019-06-19 00:39:21 +08:00
|
|
|
|
2024-10-04 03:19:33 +08:00
|
|
|
CALL H5Fcreate_f("voltest.h5",H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl_id)
|
2019-05-23 03:09:17 +08:00
|
|
|
CALL check("H5F_create_f",error,total_error)
|
|
|
|
|
|
|
|
CALL H5VLclose_f(vol_id_out, error)
|
|
|
|
CALL check("H5VLclose_f",error, total_error)
|
|
|
|
|
|
|
|
CALL H5VLclose_f(vol_id, error)
|
|
|
|
CALL check("H5VLclose_f",error, total_error)
|
|
|
|
|
|
|
|
CALL H5Fclose_f(file_id, error)
|
|
|
|
CALL check("H5Fclose_f",error,total_error)
|
|
|
|
|
|
|
|
CALL H5Pclose_f(fapl_id, error)
|
|
|
|
CALL check("H5Pclose_f",error,total_error)
|
|
|
|
|
|
|
|
END SUBROUTINE test_registration_by_fapl
|
|
|
|
|
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
END MODULE VOL_TMOD
|
|
|
|
|
|
|
|
|
|
|
|
PROGRAM vol_connector
|
|
|
|
|
|
|
|
USE VOL_TMOD
|
|
|
|
|
|
|
|
IMPLICIT NONE
|
|
|
|
INTEGER :: total_error = 0
|
|
|
|
INTEGER :: error
|
|
|
|
INTEGER :: ret_total_error
|
|
|
|
LOGICAL :: cleanup, status
|
2023-01-10 07:18:28 +08:00
|
|
|
CHARACTER(LEN=32) :: VOL_CONNECTOR_ENV
|
2019-06-19 00:39:21 +08:00
|
|
|
INTEGER :: LEN = 0
|
2023-01-06 07:42:33 +08:00
|
|
|
INTEGER :: CONN_NAME_LEN
|
2019-04-25 02:59:26 +08:00
|
|
|
|
|
|
|
CALL h5open_f(error)
|
|
|
|
cleanup = .TRUE.
|
|
|
|
CALL h5_env_nocleanup_f(status)
|
|
|
|
IF(status) cleanup=.FALSE.
|
|
|
|
|
|
|
|
WRITE(*,'(18X,A)') '=============================='
|
|
|
|
WRITE(*,'(24X,A)') 'FORTRAN VOL tests'
|
|
|
|
WRITE(*,'(18X,A)') '=============================='
|
|
|
|
|
|
|
|
WRITE(*,'(A)') "Testing VOL connector plugin functionality."
|
2019-06-19 00:39:21 +08:00
|
|
|
|
|
|
|
! Check to see if the VOL connector was set with an env variable
|
|
|
|
CALL GET_ENVIRONMENT_VARIABLE("HDF5_VOL_CONNECTOR", VOL_CONNECTOR_ENV, LEN)
|
2023-01-06 07:42:33 +08:00
|
|
|
CONN_NAME_LEN = INDEX(VOL_CONNECTOR_ENV, ' ')
|
2019-06-19 00:39:21 +08:00
|
|
|
IF(LEN.NE.0)THEN
|
2023-01-06 07:42:33 +08:00
|
|
|
NATIVE_VOL_CONNECTOR_NAME = TRIM(VOL_CONNECTOR_ENV(1:CONN_NAME_LEN))
|
2019-06-19 00:39:21 +08:00
|
|
|
ELSE
|
|
|
|
NATIVE_VOL_CONNECTOR_NAME = "native"
|
|
|
|
ENDIF
|
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
ret_total_error = 0
|
|
|
|
CALL test_registration_by_name(ret_total_error)
|
|
|
|
CALL write_test_status(ret_total_error, ' Testing VOL registration by name', total_error)
|
|
|
|
|
|
|
|
ret_total_error = 0
|
|
|
|
CALL test_registration_by_value(ret_total_error)
|
|
|
|
CALL write_test_status(ret_total_error, ' Testing VOL registration by value', total_error)
|
|
|
|
|
2019-05-23 03:09:17 +08:00
|
|
|
ret_total_error = 0
|
|
|
|
CALL test_registration_by_fapl(ret_total_error)
|
|
|
|
CALL write_test_status(ret_total_error, ' Testing VOL registration by fapl', total_error)
|
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
WRITE(*, fmt = '(/18X,A)') '============================================'
|
|
|
|
WRITE(*, fmt = '(19X, A)', advance='NO') ' FORTRAN VOL tests completed with '
|
|
|
|
WRITE(*, fmt = '(I4)', advance='NO') total_error
|
|
|
|
WRITE(*, fmt = '(A)' ) ' error(s) ! '
|
|
|
|
WRITE(*,'(18X,A)') '============================================'
|
2020-05-27 05:01:09 +08:00
|
|
|
|
2019-04-25 02:59:26 +08:00
|
|
|
CALL h5close_f(error)
|
|
|
|
|
|
|
|
! if errors detected, exit with non-zero code.
|
|
|
|
IF (total_error .NE. 0) CALL h5_exit_f(1)
|
|
|
|
|
|
|
|
END PROGRAM vol_connector
|