From 46a72f685cf96f655f0504ed98ebc22af7529013 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 16 Oct 2022 11:48:18 -0400 Subject: [PATCH] address portability issues to the flang LLVM Fortran 2018 compiler --- unittest/fortran/test_fortran_extract_variable.f90 | 4 ++-- unittest/fortran/test_fortran_gather_scatter.f90 | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/unittest/fortran/test_fortran_extract_variable.f90 b/unittest/fortran/test_fortran_extract_variable.f90 index c10e3eaa04..862cb894e5 100644 --- a/unittest/fortran/test_fortran_extract_variable.f90 +++ b/unittest/fortran/test_fortran_extract_variable.f90 @@ -60,7 +60,7 @@ CONTAINS INTERFACE FUNCTION lammps_malloc(size) BIND(C, name='malloc') - IMPORT :: c_ptr, c_size_t + USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_ptr, c_size_t IMPLICIT NONE INTEGER(c_size_t), VALUE :: size TYPE(c_ptr) :: lammps_malloc @@ -94,7 +94,7 @@ FUNCTION f_lammps_with_C_args(argc, argv) BIND(C) INTERFACE FUNCTION c_strlen(str) BIND(C,name='strlen') - IMPORT :: c_ptr, c_size_t + USE ISO_C_BINDING, ONLY: c_ptr, c_size_t IMPLICIT NONE TYPE(c_ptr), INTENT(IN), VALUE :: str INTEGER(c_size_t) :: c_strlen diff --git a/unittest/fortran/test_fortran_gather_scatter.f90 b/unittest/fortran/test_fortran_gather_scatter.f90 index ec1880c908..d9bd27bba9 100644 --- a/unittest/fortran/test_fortran_gather_scatter.f90 +++ b/unittest/fortran/test_fortran_gather_scatter.f90 @@ -71,13 +71,13 @@ FUNCTION f_lammps_gather_atoms_concat_mask(i) BIND(C) CALL lmp%gather_atoms_concat('mask', 1_c_int, mask) CALL lmp%gather_atoms_concat('id', 1_c_int, tag) + f_lammps_gather_atoms_concat_mask = -1 DO j = 1, SIZE(tag) IF (tag(j) == i) THEN f_lammps_gather_atoms_concat_mask = mask(j) - RETURN + EXIT END IF END DO - f_lammps_gather_atoms_concat_mask = -1 END FUNCTION f_lammps_gather_atoms_concat_mask FUNCTION f_lammps_gather_atoms_concat_position(xyz, id) BIND(C) @@ -93,6 +93,7 @@ FUNCTION f_lammps_gather_atoms_concat_position(xyz, id) BIND(C) CALL lmp%gather_atoms_concat('x', 3_c_int, positions) CALL lmp%gather_atoms_concat('id', 1_c_int, tag) + f_lammps_gather_atoms_concat_position = -1.0_c_double DO j = 1, SIZE(tag) IF (tag(j) == id) THEN f_lammps_gather_atoms_concat_position = positions((j-1)*3 + xyz) @@ -112,13 +113,13 @@ FUNCTION f_lammps_gather_atoms_subset_mask(i) BIND(C) INTEGER(c_int), DIMENSION(*), PARAMETER :: tag = [3,2] CALL lmp%gather_atoms_subset('mask', 1_c_int, tag, mask) + f_lammps_gather_atoms_subset_mask = -1 DO j = 1, SIZE(tag) IF (tag(j) == i) THEN f_lammps_gather_atoms_subset_mask = mask(j) - RETURN + EXIT END IF END DO - f_lammps_gather_atoms_subset_mask = -1 END FUNCTION f_lammps_gather_atoms_subset_mask FUNCTION f_lammps_gather_atoms_subset_position(xyz,id) BIND(C) @@ -133,13 +134,13 @@ FUNCTION f_lammps_gather_atoms_subset_position(xyz,id) BIND(C) INTEGER :: j CALL lmp%gather_atoms_subset('x', 3_c_int, tag, positions) + f_lammps_gather_atoms_subset_position = -1.0_c_double DO j = 1, SIZE(tag) IF (tag(j) == id) THEN f_lammps_gather_atoms_subset_position = positions((j-1)*3 + xyz) - RETURN + EXIT END IF END DO - f_lammps_gather_atoms_subset_position = -1.0D0 END FUNCTION f_lammps_gather_atoms_subset_position SUBROUTINE f_lammps_scatter_atoms_masks() BIND(C)