From f7de0957e937b6327cc519e12a4938d30849146c Mon Sep 17 00:00:00 2001 From: Yen-Chen Chen <yen-chen.chen@kit.edu> Date: Wed, 20 Nov 2024 12:13:36 +0000 Subject: [PATCH] Restore present check for set_acc_host_or_device (icon-libraries/libfortran-support!100) The present check in the `set_acc_host_or_device` is heavily used in ICON and cannot be changed easily. This problem comes from the discussion at https://gitlab.dkrz.de/icon/icon-mpim/-/merge_requests/563#note_276277 Revert the changes. Approved-by: Marek Jacob <1129-b380572@users.noreply.gitlab.dkrz.de> Merged-by: Yen-Chen Chen <yen-chen.chen@kit.edu> Changelog: bugfix --- src/mo_fortran_tools.F90 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mo_fortran_tools.F90 b/src/mo_fortran_tools.F90 index e58af34..8df4ada 100644 --- a/src/mo_fortran_tools.F90 +++ b/src/mo_fortran_tools.F90 @@ -2326,22 +2326,28 @@ CONTAINS SUBROUTINE assert_acc_host_only(routine_name, lacc) CHARACTER(len=*), INTENT(IN) :: routine_name - LOGICAL, INTENT(IN) :: lacc + LOGICAL, INTENT(IN), OPTIONAL :: lacc #ifdef _OPENACC - IF (lacc) THEN - CALL finish(routine_name, 'not supported on ACC device.') + IF (PRESENT(lacc)) THEN + IF (lacc) THEN + CALL finish(routine_name, ' not supported on ACC device.') + END IF END IF #endif END SUBROUTINE assert_acc_host_only SUBROUTINE assert_acc_device_only(routine_name, lacc) CHARACTER(len=*), INTENT(IN) :: routine_name - LOGICAL, INTENT(IN) :: lacc + LOGICAL, INTENT(IN), OPTIONAL :: lacc #ifdef _OPENACC - IF (.NOT. lacc) THEN - CALL finish(routine_name, 'not supported in ACC host mode.') + IF (.NOT. PRESENT(lacc)) THEN + CALL finish(routine_name, ' must not be called without lacc.') + ELSE + IF (.NOT. lacc) THEN + CALL finish(routine_name, ' not supported in ACC host mode.') + END IF END IF #endif END SUBROUTINE assert_acc_device_only @@ -2361,11 +2367,13 @@ CONTAINS PURE SUBROUTINE set_acc_host_or_device(lzacc, lacc) LOGICAL, INTENT(OUT) :: lzacc - LOGICAL, INTENT(IN) :: lacc + LOGICAL, INTENT(IN), OPTIONAL :: lacc lzacc = .FALSE. #ifdef _OPENACC - lzacc = lacc + IF (PRESENT(lacc)) THEN + lzacc = lacc + END IF #endif END SUBROUTINE set_acc_host_or_device -- GitLab