program test_external_registry use fem_precision use fem_error use fem_linsol_ext_registry implicit none call check_builtin_profiles() call check_unavailable_profiles() call check_capability_text() call check_status_lines() call check_backend_table() call check_error_paths() contains subroutine check_builtin_profiles() type(external_backend_profile) :: profile integer :: backend integer :: available integer :: capabilities integer :: ierr character(len=32) :: name character(len=32) :: reason call ext_registry_backend_profile(LS_EXT_BACKEND_REF_DIRECT, profile, ierr) call require_success(ierr, 10) call ext_registry_profile_values(profile, backend, available, & capabilities, name, reason, ierr) call require_success(ierr, 11) if (backend .ne. LS_EXT_BACKEND_REF_DIRECT) call fail(12) if (available .ne. 1) call fail(13) if (trim(name) .ne. 'ref_direct') call fail(14) if (trim(reason) .ne. 'built_in_reference') call fail(15) call require_direct_caps(capabilities, 16) call ext_registry_backend_profile(LS_EXT_BACKEND_FILE, profile, ierr) call require_success(ierr, 20) call ext_registry_profile_values(profile, backend, available, & capabilities, name, reason, ierr) call require_success(ierr, 21) if (backend .ne. LS_EXT_BACKEND_FILE) call fail(22) if (available .ne. 1) call fail(23) if (trim(name) .ne. 'file_exchange') call fail(24) if (trim(reason) .ne. 'file_exchange') call fail(25) call require_direct_caps(capabilities, 26) end subroutine check_builtin_profiles subroutine check_unavailable_profiles() type(external_backend_profile) :: profile integer :: available integer :: capabilities integer :: ierr character(len=32) :: name call ext_registry_capabilities(LS_EXT_BACKEND_SUPERLU, available, & capabilities, ierr) call require_success(ierr, 40) if (available .ne. 0 .or. capabilities .ne. 0) call fail(41) call ext_registry_backend_name(LS_EXT_BACKEND_SUPERLU, name, ierr) call require_success(ierr, 42) if (trim(name) .ne. 'superlu') call fail(43) call ext_registry_backend_profile(LS_EXT_BACKEND_MUMPS, profile, ierr) call require_success(ierr, 44) if (profile%available .ne. 0) call fail(45) if (trim(profile%reason) .ne. 'not_built') call fail(46) if (.not. ext_registry_valid_backend(LS_EXT_BACKEND_MKL_PARDISO)) & call fail(47) if (ext_registry_valid_backend(999)) call fail(48) end subroutine check_unavailable_profiles subroutine check_capability_text() character(len=96) :: text integer :: ierr call ext_registry_capability_text(0, text, ierr) call require_success(ierr, 60) if (trim(text) .ne. 'none') call fail(61) call ext_registry_capability_text(LS_EXT_CAP_DIRECT + LS_EXT_CAP_SPD, & text, ierr) call require_success(ierr, 62) if (index(text, 'direct') .le. 0) call fail(63) if (index(text, 'spd') .le. 0) call fail(64) if (index(text, 'general') .gt. 0) call fail(65) call ext_registry_capability_text(LS_EXT_CAP_DIRECT + & LS_EXT_CAP_GENERAL + LS_EXT_CAP_SPD + LS_EXT_CAP_INDEFINITE, text, ierr) call require_success(ierr, 66) if (index(text, 'indefinite') .le. 0) call fail(67) end subroutine check_capability_text subroutine check_status_lines() character(len=192) :: line integer :: ierr call ext_registry_status_line(LS_EXT_BACKEND_FILE, line, ierr) call require_success(ierr, 80) if (index(line, 'backend=file_exchange') .ne. 1) call fail(81) if (index(line, 'available=1') .le. 0) call fail(82) if (index(line, 'capabilities=direct,general,spd,indefinite') .le. 0) & call fail(83) call ext_registry_status_line(LS_EXT_BACKEND_SUPERLU, line, ierr) call require_success(ierr, 84) if (index(line, 'backend=superlu') .ne. 1) call fail(85) if (index(line, 'available=0') .le. 0) call fail(86) if (index(line, 'reason=not_built') .le. 0) call fail(87) end subroutine check_status_lines subroutine check_backend_table() integer :: ids(LS_EXT_BACKEND_COUNT) integer :: count integer :: available_count integer :: ierr character(len=192) :: line call ext_registry_backend_ids(ids, count, ierr) call require_success(ierr, 90) if (count .ne. LS_EXT_BACKEND_COUNT) call fail(91) if (ids(1) .ne. LS_EXT_BACKEND_NONE) call fail(92) if (ids(count) .ne. LS_EXT_BACKEND_FILE) call fail(93) call ext_registry_available_count(available_count, ierr) call require_success(ierr, 94) if (available_count .lt. 2) call fail(95) call ext_registry_table_header(line, ierr) call require_success(ierr, 96) if (index(line, 'index,backend,available') .ne. 1) call fail(97) call ext_registry_table_row(5, line, ierr) call require_success(ierr, 98) if (index(line, '5,ref_direct,1') .ne. 1) call fail(99) call ext_registry_table_row(2, line, ierr) call require_success(ierr, 100) if (index(line, '2,superlu,0') .ne. 1) call fail(101) end subroutine check_backend_table subroutine check_error_paths() type(external_backend_profile) :: profile integer :: ierr integer :: backend integer :: available integer :: capabilities character(len=4) :: small character(len=4) :: small_reason integer :: ids(1) integer :: count call ext_registry_backend_profile(999, profile, ierr) if (ierr .eq. FEM_SUCCESS) call fail(100) call ext_registry_backend_name(LS_EXT_BACKEND_FILE, small, ierr) if (ierr .eq. FEM_SUCCESS) call fail(101) call ext_registry_capability_text(LS_EXT_CAP_DIRECT + & LS_EXT_CAP_GENERAL + LS_EXT_CAP_SPD + LS_EXT_CAP_INDEFINITE, small, ierr) if (ierr .eq. FEM_SUCCESS) call fail(102) call ext_registry_backend_profile(LS_EXT_BACKEND_FILE, profile, ierr) call require_success(ierr, 103) call ext_registry_profile_values(profile, backend, available, capabilities, & small, small_reason, ierr) if (ierr .eq. FEM_SUCCESS) call fail(104) call ext_registry_backend_ids(ids, count, ierr) if (ierr .eq. FEM_SUCCESS) call fail(105) call ext_registry_table_row(0, small, ierr) if (ierr .eq. FEM_SUCCESS) call fail(106) end subroutine check_error_paths subroutine require_direct_caps(capabilities, code) integer, intent(in) :: capabilities integer, intent(in) :: code if (iand(capabilities, LS_EXT_CAP_DIRECT) .eq. 0) call fail(code) if (iand(capabilities, LS_EXT_CAP_GENERAL) .eq. 0) call fail(code + 1) if (iand(capabilities, LS_EXT_CAP_SPD) .eq. 0) call fail(code + 2) if (iand(capabilities, LS_EXT_CAP_INDEFINITE) .eq. 0) call fail(code + 3) end subroutine require_direct_caps subroutine require_success(ierr, code) integer, intent(in) :: ierr integer, intent(in) :: code if (ierr .ne. FEM_SUCCESS) call fail(code) end subroutine require_success subroutine fail(code) integer, intent(in) :: code write(*,*) 'test_external_registry failed:', code stop 1 end subroutine fail end program test_external_registry