diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a6bdd2..0684da7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ find_package( ecbuild 3.0.0 REQUIRED ) project( fckit LANGUAGES C CXX Fortran ) +set(CMAKE_DIRECTORY_LABELS "fckit") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -35,7 +36,11 @@ ecbuild_enable_fortran( REQUIRED MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/module ) ecbuild_check_fortran( FEATURES finalization ) set( FEATURE_FINAL_DEFAULT ON ) +set( PGIBUG_ATLAS_197 0 ) if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI" ) + if( ${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS 19.4 ) + set( PGIBUG_ATLAS_197 1 ) + endif() if( ${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS 19.10 ) # Compilation works, but runtime segmentation faults occur (tested with pgi/17.7) set( FEATURE_FINAL_DEFAULT OFF ) diff --git a/VERSION b/VERSION index faef31a..a3df0a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.0 +0.8.0 diff --git a/cmake/add_fctest.cmake b/cmake/add_fctest.cmake index e11f570..2eca31d 100644 --- a/cmake/add_fctest.cmake +++ b/cmake/add_fctest.cmake @@ -83,7 +83,6 @@ cmake_policy( SET CMP0064 NEW ) # Recognize ``TEST`` as operator for the ``if()` target_sources( ${_PAR_TARGET} PUBLIC ${TESTRUNNER} ) ### Add dependencies - target_include_directories( ${_PAR_TARGET} PUBLIC ${FCKIT_INCLUDE_DIRS} ) target_link_libraries( ${_PAR_TARGET} fckit ) if( TEST ${_PAR_TARGET} ) set_property( TEST ${_PAR_TARGET} APPEND PROPERTY LABELS "fortran" ) @@ -100,6 +99,17 @@ cmake_policy( SET CMP0064 NEW ) # Recognize ``TEST`` as operator for the ``if()` set_source_files_properties( ${TESTRUNNER} PROPERTIES ${_prop} ${TESTSUITE_PROPERTY} ) endif() endforeach() + if(${CMAKE_Fortran_COMPILER_ID} MATCHES GNU) + #Disable developer-only pre-processor warnings when not compiling for Debug configurations + target_compile_options(${_PAR_TARGET} PRIVATE $<$>:-Wno-cpp>) + endif() + + ### Workaround Flang issue, not able to include absolute path. Adding -I/ seems a workaround + # but results in warning for other compilers (intel) + if( ${CMAKE_Fortran_COMPILER_ID} MATCHES Flang ) + target_include_directories( ${_PAR_TARGET} PUBLIC ${FCKIT_INCLUDE_DIRS} "/" ) + endif() + add_custom_target( ${_PAR_TARGET}_testsuite SOURCES ${TESTSUITE} ) endif() diff --git a/src/fckit/Log.F90 b/src/fckit/Log.F90 index be1690a..5a58677 100644 --- a/src/fckit/Log.F90 +++ b/src/fckit/Log.F90 @@ -8,13 +8,15 @@ ! Callback function, used from C++ side subroutine fckit_write_to_fortran_unit(unit,msg_cptr) bind(C) - use, intrinsic :: iso_c_binding, only: c_int32_t, c_ptr, c_char - use fckit_c_interop_module, only : c_ptr_to_string + use, intrinsic :: iso_c_binding, only: c_int32_t, c_ptr, c_char, c_associated + use fckit_c_interop_module, only : copy_c_ptr_to_string integer(c_int32_t), value, intent(in) :: unit type(c_ptr), value, intent(in) :: msg_cptr character(kind=c_char,len=:), allocatable :: msg - msg = c_ptr_to_string(msg_cptr) - write(unit,'(A)') msg + if( c_associated(msg_cptr) ) then + call copy_c_ptr_to_string( msg_cptr, msg ) + write(unit,'(A)') msg + endif end subroutine function fckit_fortranunit_stdout() result(stdout) bind(C) diff --git a/src/fckit/fckit.h.in b/src/fckit/fckit.h.in index 8cb8ed4..52597ef 100644 --- a/src/fckit/fckit.h.in +++ b/src/fckit/fckit.h.in @@ -37,18 +37,23 @@ does it submit to any jurisdiction. associate( unused_ => X ); \ end associate -#define PGIBUG_ATLAS_197 1 +#define PGIBUG_ATLAS_197 @PGIBUG_ATLAS_197@ #if 0 Following is to workaround PGI bug which prevents the use of function c_ptr() +PGI bug present from version 17.10, fixed since version 19.4 #endif #if PGIBUG_ATLAS_197 #define CPTR_PGIBUG_A cpp_object_ptr #define CPTR_PGIBUG_B shared_object_%cpp_object_ptr -#define PGIBUG_ATLAS_197_DEBUG 0 #else #define CPTR_PGIBUG_A c_ptr() #define CPTR_PGIBUG_B c_ptr() +#endif + #define PGIBUG_ATLAS_197_DEBUG 0 +#if 0 +When above PGIBUG_ATLAS_197_DEBUG==1 then the c_ptr() member functions are disabled from compilation, +to detect possible dangerous use cases when the PGI bug ATLAS-197 is present. #endif #define XLBUG_FCKIT_14 1 diff --git a/src/fckit/module/fckit_C_interop.F90 b/src/fckit/module/fckit_C_interop.F90 index 85326c2..4147601 100644 --- a/src/fckit/module/fckit_C_interop.F90 +++ b/src/fckit/module/fckit_C_interop.F90 @@ -21,6 +21,8 @@ module fckit_C_interop_module public :: get_c_commandline_arguments public :: c_str_to_string public :: c_ptr_to_string +public :: copy_c_ptr_to_string +public :: copy_c_str_to_string public :: c_str public :: c_str_no_trim public :: c_str_right_trim @@ -157,6 +159,37 @@ function c_str_to_string(s) result(string) ! ============================================================================= +subroutine copy_c_str_to_string(s,string) + use, intrinsic :: iso_c_binding + character(kind=c_char,len=1), intent(in) :: s(*) + character(len=:), allocatable :: string + integer i, nchars + i = 1 + do + if (s(i) == c_null_char) exit + i = i + 1 + enddo + nchars = i - 1 ! Exclude null character from Fortran string + FCKIT_ALLOCATE_CHARACTER(string,nchars) + do i=1,nchars + string(i:i) = s(i) + enddo +end subroutine + +! ============================================================================= + +subroutine copy_c_ptr_to_string(cptr,string) + use, intrinsic :: iso_c_binding + type(c_ptr), intent(in) :: cptr + character(kind=c_char,len=:), allocatable :: string + character(kind=c_char), dimension(:), pointer :: s + integer(c_int), parameter :: MAX_STR_LEN = 255 + call c_f_pointer ( cptr , s, (/MAX_STR_LEN/) ) + call copy_c_str_to_string( s, string ) +end subroutine + +! ============================================================================= + function c_ptr_to_string(cptr) result(string) use, intrinsic :: iso_c_binding type(c_ptr), intent(in) :: cptr @@ -164,7 +197,7 @@ function c_ptr_to_string(cptr) result(string) character(kind=c_char), dimension(:), pointer :: s integer(c_int), parameter :: MAX_STR_LEN = 255 call c_f_pointer ( cptr , s, (/MAX_STR_LEN/) ) - string = c_str_to_string(s) + call copy_c_str_to_string( s, string ) end function ! ============================================================================= diff --git a/src/fckit/module/fckit_array.F90 b/src/fckit/module/fckit_array.F90 index 960af4a..3d74c0f 100644 --- a/src/fckit/module/fckit_array.F90 +++ b/src/fckit/module/fckit_array.F90 @@ -6,6 +6,8 @@ ! granted to it by virtue of its status as an intergovernmental organisation nor ! does it submit to any jurisdiction. +#include "fckit.h" + module fckit_array_module use, intrinsic :: iso_c_binding, only: c_int32_t, c_int64_t, c_float, c_double implicit none @@ -168,6 +170,7 @@ function array_view1d_int32_r0(scalar,mold) result( view ) nullify(view) array_c_ptr = c_loc_int32(scalar) call c_f_pointer ( array_c_ptr , view , (/1/) ) + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -185,6 +188,7 @@ function array_view1d_int32_r1(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -202,6 +206,7 @@ function array_view1d_int32_r2(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -219,6 +224,7 @@ function array_view1d_int32_r3(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -236,6 +242,7 @@ function array_view1d_int32_r4(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -249,6 +256,7 @@ function array_view1d_int64_r0(scalar,mold) result( view ) nullify(view) array_c_ptr = c_loc_int64(scalar) call c_f_pointer ( array_c_ptr , view , (/1/) ) + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -266,6 +274,7 @@ function array_view1d_int64_r1(array,mold) result( view ) else view => zero_length_array_int64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -283,6 +292,7 @@ function array_view1d_int64_r2(array,mold) result( view ) else view => zero_length_array_int64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -300,6 +310,7 @@ function array_view1d_int64_r3(array,mold) result( view ) else view => zero_length_array_int64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -317,6 +328,7 @@ function array_view1d_int64_r4(array,mold) result( view ) else view => zero_length_array_int64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -330,6 +342,7 @@ function array_view1d_real32_r0(scalar,mold) result( view ) nullify(view) array_c_ptr = c_loc_real32(scalar) call c_f_pointer ( array_c_ptr , view , (/1/) ) + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -347,6 +360,7 @@ function array_view1d_real32_r1(array,mold) result( view ) else view => zero_length_array_real32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -364,6 +378,7 @@ function array_view1d_real32_r2(array,mold) result( view ) else view => zero_length_array_real32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -381,6 +396,7 @@ function array_view1d_real32_r3(array,mold) result( view ) else view => zero_length_array_real32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -398,6 +414,7 @@ function array_view1d_real32_r4(array,mold) result( view ) else view => zero_length_array_real32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -411,6 +428,7 @@ function array_view1d_real64_r0(scalar,mold) result( view ) nullify(view) array_c_ptr = c_loc_real64(scalar) call c_f_pointer ( array_c_ptr , view , (/1/) ) + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -428,6 +446,7 @@ function array_view1d_real64_r1(array,mold) result( view ) else view => zero_length_array_real64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -445,6 +464,7 @@ function array_view1d_real64_r2(array,mold) result( view ) else view => zero_length_array_real64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -462,6 +482,7 @@ function array_view1d_real64_r3(array,mold) result( view ) else view => zero_length_array_real64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -479,6 +500,7 @@ function array_view1d_real64_r4(array,mold) result( view ) else view => zero_length_array_real64 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -568,6 +590,7 @@ function array_view1d_logical_r0_mold_int32(scalar,mold) result( view ) nullify(view) array_c_ptr = c_loc_logical(scalar) call c_f_pointer ( array_c_ptr , view , (/1/) ) + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -585,6 +608,7 @@ function array_view1d_logical_r1_mold_int32(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -602,6 +626,7 @@ function array_view1d_logical_r2_mold_int32(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -619,6 +644,7 @@ function array_view1d_logical_r3_mold_int32(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -636,6 +662,7 @@ function array_view1d_logical_r4_mold_int32(array,mold) result( view ) else view => zero_length_array_int32 endif + FCKIT_SUPPRESS_UNUSED(mold) end function ! ============================================================================= @@ -647,7 +674,7 @@ function array_stride_int32_r1_dim(arr,dim) result( stride ) integer(c_int32_t) :: dim integer(c_int32_t) :: stride stride = 1 - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2))-loc(arr(1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2))-loc(arr(1)),c_int32_t)/int(4,c_int32_t) end function ! ============================================================================= @@ -659,8 +686,8 @@ function array_stride_int32_r2_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1))-loc(arr(1,1)))/4 - if (dim == 2 .AND. ubound(arr,1) > 1) stride = (loc(arr(1,2))-loc(arr(1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,1) > 1) stride = int(loc(arr(1,2))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -675,9 +702,9 @@ function array_stride_int32_r3_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1))-loc(arr(1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1))-loc(arr(1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2))-loc(arr(1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -692,10 +719,10 @@ function array_stride_int32_r4_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2,1))-loc(arr(1,1,1,1)))/4 - if (dim == 4 .AND. ubound(arr,4) > 1) stride = (loc(arr(1,1,1,2))-loc(arr(1,1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 4 .AND. ubound(arr,4) > 1) stride = int(loc(arr(1,1,1,2))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -709,7 +736,7 @@ function array_stride_int64_r1_dim(arr,dim) result( stride ) integer(c_int32_t) :: dim integer(c_int32_t) :: stride stride = 1 - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2))-loc(arr(1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2))-loc(arr(1)),c_int32_t)/int(4,c_int32_t) end function ! ============================================================================= @@ -721,8 +748,8 @@ function array_stride_int64_r2_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1))-loc(arr(1,1)))/4 - if (dim == 2 .AND. ubound(arr,1) > 1) stride = (loc(arr(1,2))-loc(arr(1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,1) > 1) stride = int(loc(arr(1,2))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -737,9 +764,9 @@ function array_stride_int64_r3_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1))-loc(arr(1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1))-loc(arr(1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2))-loc(arr(1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -754,10 +781,10 @@ function array_stride_int64_r4_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2,1))-loc(arr(1,1,1,1)))/4 - if (dim == 4 .AND. ubound(arr,4) > 1) stride = (loc(arr(1,1,1,2))-loc(arr(1,1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 4 .AND. ubound(arr,4) > 1) stride = int(loc(arr(1,1,1,2))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -772,7 +799,7 @@ function array_stride_real32_r1_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2))-loc(arr(1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2))-loc(arr(1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -787,8 +814,8 @@ function array_stride_real32_r2_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1))-loc(arr(1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2))-loc(arr(1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -803,9 +830,9 @@ function array_stride_real32_r3_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1))-loc(arr(1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1))-loc(arr(1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2))-loc(arr(1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -820,10 +847,10 @@ function array_stride_real32_r4_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2,1))-loc(arr(1,1,1,1)))/4 - if (dim == 4 .AND. ubound(arr,4) > 1) stride = (loc(arr(1,1,1,2))-loc(arr(1,1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 4 .AND. ubound(arr,4) > 1) stride = int(loc(arr(1,1,1,2))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -838,7 +865,7 @@ function array_stride_real64_r1_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2))-loc(arr(1)))/8 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2))-loc(arr(1)),c_int32_t)/int(8,c_int32_t) else stride = 0 endif @@ -853,8 +880,8 @@ function array_stride_real64_r2_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1))-loc(arr(1,1)))/8 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2))-loc(arr(1,1)))/8 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1))-loc(arr(1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2))-loc(arr(1,1)),c_int32_t)/int(8,c_int32_t) else stride = 0 endif @@ -869,9 +896,9 @@ function array_stride_real64_r3_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1))-loc(arr(1,1,1)))/8 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1))-loc(arr(1,1,1)))/8 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2))-loc(arr(1,1,1)))/8 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1))-loc(arr(1,1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1))-loc(arr(1,1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2))-loc(arr(1,1,1)),c_int32_t)/int(8,c_int32_t) else stride = 0 endif @@ -886,10 +913,10 @@ function array_stride_real64_r4_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1,1))-loc(arr(1,1,1,1)))/8 - if (dim == 2) stride = (loc(arr(1,2,1,1))-loc(arr(1,1,1,1)))/8 - if (dim == 3) stride = (loc(arr(1,1,2,1))-loc(arr(1,1,1,1)))/8 - if (dim == 4) stride = (loc(arr(1,1,1,2))-loc(arr(1,1,1,1)))/8 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 2) stride = int(loc(arr(1,2,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 3) stride = int(loc(arr(1,1,2,1))-loc(arr(1,1,1,1)),c_int32_t)/int(8,c_int32_t) + if (dim == 4) stride = int(loc(arr(1,1,1,2))-loc(arr(1,1,1,1)),c_int32_t)/int(8,c_int32_t) else stride = 0 endif @@ -904,7 +931,7 @@ function array_stride_logical_r1_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr) > 0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2))-loc(arr(1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2))-loc(arr(1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -919,8 +946,8 @@ function array_stride_logical_r2_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1))-loc(arr(1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2))-loc(arr(1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2))-loc(arr(1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -935,9 +962,9 @@ function array_stride_logical_r3_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1))-loc(arr(1,1,1)))/4 - if (dim == 2 .AND. ubound(arr,2) > 1) stride = (loc(arr(1,2,1))-loc(arr(1,1,1)))/4 - if (dim == 3 .AND. ubound(arr,3) > 1) stride = (loc(arr(1,1,2))-loc(arr(1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2 .AND. ubound(arr,2) > 1) stride = int(loc(arr(1,2,1))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3 .AND. ubound(arr,3) > 1) stride = int(loc(arr(1,1,2))-loc(arr(1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif @@ -952,10 +979,10 @@ function array_stride_logical_r4_dim(arr,dim) result( stride ) integer(c_int32_t) :: stride stride = 1 if( size(arr)>0 ) then - if (dim == 1 .AND. ubound(arr,1) > 1) stride = (loc(arr(2,1,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 2) stride = (loc(arr(1,2,1,1))-loc(arr(1,1,1,1)))/4 - if (dim == 3) stride = (loc(arr(1,1,2,1))-loc(arr(1,1,1,1)))/4 - if (dim == 4) stride = (loc(arr(1,1,1,2))-loc(arr(1,1,1,1)))/4 + if (dim == 1 .AND. ubound(arr,1) > 1) stride = int(loc(arr(2,1,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 2) stride = int(loc(arr(1,2,1,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 3) stride = int(loc(arr(1,1,2,1))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) + if (dim == 4) stride = int(loc(arr(1,1,1,2))-loc(arr(1,1,1,1)),c_int32_t)/int(4,c_int32_t) else stride = 0 endif diff --git a/src/fckit/module/fckit_buffer.F90 b/src/fckit/module/fckit_buffer.F90 index 58d9ec0..186216c 100644 --- a/src/fckit/module/fckit_buffer.F90 +++ b/src/fckit/module/fckit_buffer.F90 @@ -109,6 +109,7 @@ function str(this) !======================================================================== +#if FCKIT_FINAL_NOT_INHERITING FCKIT_FINAL subroutine fckit_buffer__final_auto(this) type(fckit_buffer), intent(inout) :: this #if FCKIT_FINAL_DEBUGGING @@ -119,5 +120,6 @@ FCKIT_FINAL subroutine fckit_buffer__final_auto(this) #endif FCKIT_SUPPRESS_UNUSED( this ) end subroutine +#endif end module diff --git a/src/fckit/module/fckit_configuration.F90 b/src/fckit/module/fckit_configuration.F90 index b0f312a..cd2c8f0 100644 --- a/src/fckit/module/fckit_configuration.F90 +++ b/src/fckit/module/fckit_configuration.F90 @@ -77,6 +77,14 @@ module fckit_configuration_module !!```fortran !! if( .not. fckit_configuration%has('levels') ) call abort() !!``` + procedure, public :: get_size + !! Function that returns the size of a name in the configuration + !! + !!#### Example usage: + !! + !!```fortran + !! nlev = fckit_configuration%get_size('levels') + !!``` procedure, private :: set_config procedure, private :: set_config_list @@ -86,6 +94,7 @@ module fckit_configuration_module procedure, private :: set_real32 procedure, private :: set_real64 procedure, private :: set_string + procedure, private :: set_array_string procedure, private :: set_array_int32 procedure, private :: set_array_int64 procedure, private :: set_array_real32 @@ -127,6 +136,7 @@ module fckit_configuration_module set_real32, & set_real64, & set_string, & + set_array_string, & set_array_int32, & set_array_int64, & set_array_real32, & @@ -140,6 +150,7 @@ module fckit_configuration_module procedure, private :: get_real32 procedure, private :: get_real64 procedure, private :: get_string + procedure, private :: get_array_logical procedure, private :: get_array_int32 procedure, private :: get_array_int64 procedure, private :: get_array_real32 @@ -198,6 +209,7 @@ module fckit_configuration_module get_real32, & get_real64, & get_string, & + get_array_logical, & get_array_int32, & get_array_int64, & get_array_real32, & @@ -212,6 +224,7 @@ module fckit_configuration_module procedure, private :: get_real32_or_die procedure, private :: get_real64_or_die procedure, private :: get_string_or_die + procedure, private :: get_array_logical_or_die procedure, private :: get_array_int32_or_die procedure, private :: get_array_int64_or_die procedure, private :: get_array_real32_or_die @@ -256,6 +269,7 @@ module fckit_configuration_module get_real32_or_die, & get_real64_or_die, & get_string_or_die, & + get_array_logical_or_die, & get_array_int32_or_die, & get_array_int64_or_die, & get_array_real32_or_die, & @@ -327,6 +341,7 @@ subroutine deallocate_fckit_configuration( array ) endif end subroutine +#if FCKIT_FINAL_NOT_INHERITING FCKIT_FINAL subroutine fckit_configuration__final_auto(this) type(fckit_configuration), intent(inout) :: this #if FCKIT_FINAL_DEBUGGING @@ -337,6 +352,7 @@ FCKIT_FINAL subroutine fckit_configuration__final_auto(this) #endif FCKIT_SUPPRESS_UNUSED( this ) end subroutine +#endif function ctor() result(this) type(fckit_Configuration) :: this @@ -392,7 +408,7 @@ function ctor_from_buffer(buffer) result(this) function has(this, name) result(value) use fckit_c_interop_module, only : c_str - class(fckit_Configuration), intent(inout) :: this + class(fckit_Configuration), intent(in) :: this character(kind=c_char,len=*), intent(in) :: name logical :: value integer(c_int32_t) :: value_int @@ -404,6 +420,14 @@ function has(this, name) result(value) end if end function +function get_size(this, name) result(val) + use fckit_c_interop_module, only : c_str + class(fckit_Configuration), intent(in) :: this + character(kind=c_char,len=*), intent(in) :: name + integer(c_int32_t) :: val + val = c_fckit_configuration_get_size(this%CPTR_PGIBUG_B, c_str(name) ) +end function + subroutine set_config(this, name, value) use fckit_c_interop_module, only : c_str class(fckit_Configuration), intent(inout) :: this @@ -484,6 +508,27 @@ subroutine set_string(this, name, value) call c_fckit_configuration_set_string(this%CPTR_PGIBUG_B, c_str(name) , c_str(value) ) end subroutine +subroutine set_array_string(this, name, value) + use, intrinsic :: iso_c_binding, only : c_f_pointer + use fckit_c_interop_module, only : c_str, c_ptr_to_string, c_ptr_free + class(fckit_Configuration), intent(in) :: this + character(kind=c_char,len=*), intent(in) :: name + character(kind=c_char,len=*), intent(in) :: value(:) + character(kind=c_char,len=:), allocatable :: flatvalue + integer(c_size_t) :: length + integer(c_int32_t) :: ii + length = 0 + if( size(value) > 0 ) then + length = len(value(1)) + allocate( character(len=length*size(value) ) :: flatvalue ) + do ii = 1, size(value) + flatvalue((ii-1)*length+1:ii*length) = value(ii) + enddo + call c_fckit_configuration_set_array_string(this%CPTR_PGIBUG_B, c_str(name), & + & c_str(flatvalue), length, size(value,kind=c_size_t) ) + endif +end subroutine + subroutine set_array_int32(this, name, value) use fckit_c_interop_module, only : c_str class(fckit_Configuration), intent(in) :: this @@ -550,7 +595,7 @@ function get_config_list(this, name, value) result(found) type(c_ptr), pointer :: value_cptrs(:) integer(c_size_t) :: value_list_size integer(c_int32_t) :: found_int - integer(c_int32_t) :: j + integer(c_size_t) :: j call deallocate_fckit_configuration(value) value_list_cptr = c_null_ptr found_int = c_fckit_configuration_get_config_list(this%CPTR_PGIBUG_B, c_str(name), & @@ -703,6 +748,46 @@ subroutine get_string_or_die(this,name,value) if( .not. this%get(name,value) ) call throw_configuration_not_found(name) end subroutine +function get_array_logical(this, name, value) result(found) + use, intrinsic :: iso_c_binding, only : c_f_pointer + use fckit_c_interop_module, only : c_str, c_ptr_free + logical :: found + class(fckit_Configuration), intent(in) :: this + character(kind=c_char,len=*), intent(in) :: name + logical, allocatable, intent(inout) :: value(:) + type(c_ptr) :: value_cptr + integer(c_int32_t), pointer :: value_fptr(:) + integer(c_size_t) :: j, value_size + integer(c_int32_t), allocatable :: value_int(:) + integer(c_int32_t) :: found_int + found_int = c_fckit_configuration_get_array_int32(this%CPTR_PGIBUG_B, c_str(name), & + & value_cptr, value_size ) + if (found_int ==1 ) then + call c_f_pointer(value_cptr,value_fptr,(/value_size/)) + allocate(value_int(value_size)) + value_int(:) = value_fptr(:) + if( allocated(value) ) deallocate(value) + allocate(value(value_size)) + do j = 1, value_size + if (value_int(j) > 0) then + value(j) = .True. + else + value(j) = .False. + end if + end do + call c_ptr_free(value_cptr) + endif + found = .False. + if (found_int == 1) found = .True. +end function + +subroutine get_array_logical_or_die(this,name,value) + class(fckit_Configuration), intent(in) :: this + character(kind=c_char,len=*), intent(in) :: name + logical, allocatable, intent(inout) :: value(:) + if( .not. this%get(name,value) ) call throw_configuration_not_found(name) +end subroutine + function get_array_int32(this, name, value) result(found) use, intrinsic :: iso_c_binding, only : c_f_pointer use fckit_c_interop_module, only : c_str, c_ptr_free @@ -843,7 +928,7 @@ function get_array_string(this,name,value) result(found) integer(c_int32_t) :: found_int integer(c_size_t) :: maxelemlen integer(c_size_t) :: elemlen - integer :: j + integer(c_size_t) :: j character(len=:), allocatable :: flatvalue found_int = c_fckit_configuration_get_array_string(this%CPTR_PGIBUG_B, c_str(name), & & value_cptr, value_size, offsets_cptr, value_numelem) diff --git a/src/fckit/module/fckit_configuration.cc b/src/fckit/module/fckit_configuration.cc index 7f4bc32..1b21008 100644 --- a/src/fckit/module/fckit_configuration.cc +++ b/src/fckit/module/fckit_configuration.cc @@ -159,6 +159,21 @@ void c_fckit_configuration_set_string( Configuration* This, const char* name, co throw NotLocalConfiguration( Here() ); } +void c_fckit_configuration_set_array_string( Configuration* This, const char* name, const char* value, size_t length, + size_t size ) { + ASSERT( This != nullptr ); + vector v; + for ( size_t jj = 0; jj < size; ++jj ) { + char str[length + 1]; + ASSERT( snprintf( str, sizeof( str ), "%s", value + jj * length ) >= 0 ); + v.push_back( string( str ) ); + } + if ( LocalConfiguration* local = dynamic_cast( This ) ) + local->set( string( name ), v ); + else + throw NotLocalConfiguration( Here() ); +} + void c_fckit_configuration_set_array_int32( Configuration* This, const char* name, int32 value[], size_t size ) { ASSERT( This != nullptr ); vector v; @@ -327,16 +342,19 @@ int32 c_fckit_configuration_get_array_string( const Configuration* This, const c offsets[j] = size; size += s[j].size(); } - value = new char[size]; + value = new char[size + 1]; for ( size_t j = 0; j < numelem; ++j ) { strcpy( &value[offsets[j]], s[j].c_str() ); } return true; } - int32 c_fckit_configuration_has( const Configuration* This, const char* name ) { - return This->has( string( name ) ); + return This->has( name ); +} + +int32 c_fckit_configuration_get_size( const Configuration* This, const char* name ) { + return This->getStringVector( name ).size(); } void c_fckit_configuration_json( const Configuration* This, char*& json, size_t& size ) { diff --git a/src/fckit/module/fckit_configuration.inc b/src/fckit/module/fckit_configuration.inc index 9c6f577..45c7fb2 100644 --- a/src/fckit/module/fckit_configuration.inc +++ b/src/fckit/module/fckit_configuration.inc @@ -176,6 +176,21 @@ subroutine c_fckit_configuration_set_string( This, name, value ) bind(C,name="c& end subroutine !------------------------------------------------------------------------------- +!------------------------------------------------------------------------------- +! void c_fckit_configuration_set_array_string (Configuration* This, const char* n +! ame, const char* value, size_t size) +!------------------------------------------------------------------------------- +subroutine c_fckit_configuration_set_array_string( This, name, value, length, size ) bin& + &d(C,name="c_fckit_configuration_set_array_string") + use iso_c_binding, only: c_int32_t, c_size_t, c_ptr, c_char + type(c_ptr), value :: This + character(c_char), dimension(*) :: name + character(c_char), dimension(*) :: value + integer(c_size_t), value :: length + integer(c_size_t), value :: size +end subroutine +!------------------------------------------------------------------------------- + !------------------------------------------------------------------------------- ! void c_fckit_configuration_set_array_int32 (Configuration* This, const char* n ! ame, int32 value[], size_t size) @@ -435,6 +450,17 @@ function c_fckit_configuration_has( This, name ) bind(C,name="c_fckit_configura& end function !------------------------------------------------------------------------------- +!------------------------------------------------------------------------------- +! int32 c_fckit_configuration_get_size (const Configuration* This, const char *name) +!------------------------------------------------------------------------------- +function c_fckit_configuration_get_size( This, name ) bind(C,name="c_fckit_configura& + &tion_get_size") + use iso_c_binding, only: c_char, c_ptr, c_int32_t + integer(c_int32_t) :: c_fckit_configuration_get_size + type(c_ptr), value :: This + character(c_char), dimension(*) :: name +end function +!------------------------------------------------------------------------------- !------------------------------------------------------------------------------- ! void c_fckit_configuration_json(const Configuration* This, char* &json, int &s diff --git a/src/fckit/module/fckit_exception.F90 b/src/fckit/module/fckit_exception.F90 index 5f91e5e..01e7ec2 100644 --- a/src/fckit/module/fckit_exception.F90 +++ b/src/fckit/module/fckit_exception.F90 @@ -69,7 +69,7 @@ module fckit_exception_module !! call fckit_exception%throw("I have my reasons",___FILE___,___LINE___) !!``` - procedure, public, nopass :: abort + procedure, public, nopass :: abort => fckit_exception__abort !! Throw the ```eckit::Abort``` exception !! !!####Example usage @@ -131,7 +131,7 @@ subroutine set_handler( exception_handler ) !------------------------------------------------------------------------------ -subroutine abort( what, file, line, function ) +subroutine fckit_exception__abort( what, file, line, function ) use, intrinsic :: iso_c_binding, only : c_char, c_int32_t use fckit_c_interop_module, only : c_str @@ -155,13 +155,17 @@ subroutine abort( what, file, line, function ) character(kind=c_char,len=:), allocatable :: opt_function if( present(what) ) then + allocate( character(len=len_trim(what)) :: opt_what ) opt_what = what else + allocate( character(len=0) :: opt_what ) opt_what = "" endif if( present(file) ) then + allocate( character(len=len_trim(file)) :: opt_file ) opt_file = file else + allocate( character(len=0) :: opt_file ) opt_file = "" endif if( present(line) ) then @@ -170,8 +174,10 @@ subroutine abort( what, file, line, function ) opt_line = 0 endif if( present(function) ) then + allocate( character(len=len_trim(function)) :: opt_function ) opt_function = function else + allocate( character(len=0) :: opt_function ) opt_function = "" endif @@ -306,8 +312,10 @@ subroutine throw( what, file, line, function ) character(kind=c_char,len=:), allocatable :: opt_function if( present(file) ) then + allocate( character(len=len_trim(file)) :: opt_file ) opt_file = file else + allocate( character(len=0) :: opt_file ) opt_file = "" endif if( present(line) ) then @@ -316,8 +324,10 @@ subroutine throw( what, file, line, function ) opt_line = 0 endif if( present(function) ) then + allocate( character(len=len_trim(function)) :: opt_function ) opt_function = function else + allocate( character(len=0) :: opt_function ) opt_function = "" endif diff --git a/src/fckit/module/fckit_log.F90 b/src/fckit/module/fckit_log.F90 index 484e53a..a08a62c 100644 --- a/src/fckit/module/fckit_log.F90 +++ b/src/fckit/module/fckit_log.F90 @@ -68,7 +68,7 @@ module fckit_log_module procedure, nopass, public :: reset !! Reset all log channels (No more logging) - procedure, nopass, public :: flush + procedure, nopass, public :: flush => fckit_log__flush !! Flush all log channels (empty buffers) procedure, nopass, public :: add_stdout @@ -315,7 +315,7 @@ subroutine reset() call fckit__log_reset() end subroutine -subroutine flush() +subroutine fckit_log__flush() call fckit__log_flush() end subroutine diff --git a/src/fckit/module/fckit_mpi.fypp b/src/fckit/module/fckit_mpi.fypp index 9d93bac..90acf02 100644 --- a/src/fckit/module/fckit_mpi.fypp +++ b/src/fckit/module/fckit_mpi.fypp @@ -166,10 +166,10 @@ contains procedure, public :: communicator !! Fortran MPI communicator handle - procedure, public :: size + procedure, public :: size => fckit_mpi__size !! Number of MPI tasks participating in this communicator - procedure, public :: rank + procedure, public :: rank => fckit_mpi__rank !! Rank of this MPI task in this communicator procedure, public :: barrier @@ -181,7 +181,7 @@ contains procedure, public :: delete !! Delete communicator ( throws error if this is also the default ) - procedure, public :: abort + procedure, public :: abort => fckit_mpi__abort !! MPI Abort procedure, public :: anytag @@ -261,6 +261,7 @@ type(fckit_mpi_comm) :: fckit_mpi interface fckit_mpi_comm module procedure comm_constructor + module procedure comm_wrap_ptr module procedure comm_wrap end interface @@ -625,6 +626,13 @@ function comm_constructor(name) result(this) endif end function +function comm_wrap_ptr(comm) result(this) + use, intrinsic :: iso_c_binding, only: c_ptr + type(fckit_mpi_comm) :: this + type(c_ptr), intent(in) :: comm + call this%reset_c_ptr( comm ) +end function + function comm_wrap(comm) result(this) use, intrinsic :: iso_c_binding , only: c_int32_t type(fckit_mpi_comm) :: this @@ -688,7 +696,7 @@ end function !--------------------------------------------------------------------------------------- -function rank(this) +function fckit_mpi__rank(this) result(rank) use, intrinsic :: iso_c_binding, only : c_int32_t integer(c_int32_t) :: rank class(fckit_mpi_comm), intent(in) :: this @@ -697,7 +705,7 @@ end function !--------------------------------------------------------------------------------------- -function size(this) +function fckit_mpi__size(this) result(size) use, intrinsic :: iso_c_binding, only : c_int32_t integer(c_int32_t) :: size class(fckit_mpi_comm), intent(in) :: this @@ -731,7 +739,7 @@ end subroutine !--------------------------------------------------------------------------------------- -subroutine abort(this,error_code) +subroutine fckit_mpi__abort(this,error_code) use, intrinsic :: iso_c_binding, only : c_int32_t class(fckit_mpi_comm), intent(in) :: this integer(c_int32_t), intent(in), optional :: error_code @@ -756,10 +764,10 @@ subroutine allgather_${dtype}$_r0(this,in,out) ${ftype}$, intent(inout) :: out(:) ${btype}$, pointer :: view_in(:) ${btype}$, pointer :: view_out(:) - ${btype}$ :: mold + ${btype}$ :: mold view_in => array_view1d(in,mold) view_out => array_view1d(out,mold) - call fckit__mpi__allgather_${dtype}$(this%c_ptr(),view_in(1),view_out) + call fckit__mpi__allgather_${dtype}$(this%CPTR_PGIBUG_A,view_in(1),view_out) end subroutine !--------------------------------------------------------------------------------------- @@ -775,6 +783,7 @@ subroutine allgatherv_${dtype}$_r0(this,in,out,dummy) FCKIT_SUPPRESS_UNUSED( this ) FCKIT_SUPPRESS_UNUSED( in ) FCKIT_SUPPRESS_UNUSED( out ) + FCKIT_SUPPRESS_UNUSED( dummy ) end subroutine !--------------------------------------------------------------------------------------- @@ -831,7 +840,7 @@ subroutine allgather_${dtype}$_r${rank}$(this,in,out,sendcount) view_out => array_view1d(out,mold) view_rc => array_view1d(recvcounts) view_dp => array_view1d(displs) - call fckit__mpi__allgatherv_${dtype}$(this%c_ptr(),view_in,view_out,int(sendcount,c_size_t),view_rc,view_dp) + call fckit__mpi__allgatherv_${dtype}$(this%CPTR_PGIBUG_A,view_in,view_out,int(sendcount,c_size_t),view_rc,view_dp) deallocate(recvcounts,displs) end subroutine @@ -852,7 +861,7 @@ subroutine allgatherv_${dtype}$_r${rank}$(this,in,out,sendcount,recvcounts,displ view_out => array_view1d(out,mold) view_rc => array_view1d(recvcounts) view_dp => array_view1d(displs) - call fckit__mpi__allgatherv_${dtype}$(this%c_ptr(),view_in,view_out,int(sendcount,c_size_t),view_rc,view_dp) + call fckit__mpi__allgatherv_${dtype}$(this%CPTR_PGIBUG_A,view_in,view_out,int(sendcount,c_size_t),view_rc,view_dp) end subroutine !--------------------------------------------------------------------------------------- @@ -875,7 +884,7 @@ subroutine alltoallv_${dtype}$_r${rank}$(this,in,scounts,sdispl,out,rcounts,rdis view_sd => array_view1d(sdispl) view_rc => array_view1d(rcounts) view_rd => array_view1d(rdispl) - call fckit__mpi__alltoallv_${dtype}$(this%c_ptr(),view_in,view_sc,view_sd,view_out,view_rc,view_rd) + call fckit__mpi__alltoallv_${dtype}$(this%CPTR_PGIBUG_A,view_in,view_sc,view_sd,view_out,view_rc,view_rd) end subroutine !--------------------------------------------------------------------------------------- @@ -908,7 +917,7 @@ subroutine broadcast_string(this,buffer,root) enddo c_string(len(buffer)+1) = c_null_char endif - call fckit__mpi__broadcast_string(this%c_ptr(),c_string,int(len(buffer)+1,c_size_t),int(root,c_size_t)) + call fckit__mpi__broadcast_string(this%CPTR_PGIBUG_A,c_string,int(len(buffer)+1,c_size_t),int(root,c_size_t)) do j=1,len(buffer) buffer(j:j) = c_string(j) enddo @@ -948,7 +957,7 @@ subroutine allreduce_${dtype}$_r${rank}$(this,in,out,operation) use, intrinsic :: iso_c_binding use fckit_array_module, only: array_view1d - + class(fckit_mpi_comm), intent(in) :: this !! This communicator ${ftype}$, intent(in) :: in${dim[rank]}$ @@ -973,7 +982,7 @@ subroutine allreduce_inplace_${dtype}$_r${rank}$(this,inout,operation) use, intrinsic :: iso_c_binding use fckit_array_module, only: array_view1d - + class(fckit_mpi_comm), intent(in) :: this !! This communicator ${ftype}$, intent(inout) :: inout${dim[rank]}$ @@ -1004,7 +1013,7 @@ subroutine broadcast_${dtype}$_r${rank}$(this,buffer,root) !! MPI rank to broadcast from ${btype}$, pointer :: view_buffer(:) - ${btype}$ :: mold + ${btype}$ :: mold view_buffer => array_view1d(buffer,mold) call fckit__mpi__broadcast_${dtype}$(this%CPTR_PGIBUG_A,view_buffer, & int(ubound(view_buffer,1),c_size_t),int(root,c_size_t)) @@ -1041,7 +1050,7 @@ subroutine receive_${dtype}$_r${rank}$(this,buffer,source,tag,status) use, intrinsic :: iso_c_binding use fckit_array_module, only: array_view1d - + class(fckit_mpi_comm), intent(in) :: this !! This communicator ${ftype}$, intent(inout) :: buffer${dim[rank]}$ @@ -1076,7 +1085,7 @@ function isend_${dtype}$_r${rank}$(this,buffer,dest,tag) result(request) use, intrinsic :: iso_c_binding use fckit_array_module, only: array_view1d - + integer(c_int32_t) :: request !! Returned MPI request class(fckit_mpi_comm), intent(in) :: this diff --git a/src/fckit/module/fckit_object.F90 b/src/fckit/module/fckit_object.F90 index 83d94b6..96dfb25 100644 --- a/src/fckit/module/fckit_object.F90 +++ b/src/fckit/module/fckit_object.F90 @@ -44,7 +44,7 @@ module fckit_object_module procedure, public :: is_null !! Check if internal C pointer is set -#if !PGIBUG_ATLAS_197_DEBUG +#if !PGIBUG_ATLAS_197 procedure, public :: c_ptr => fckit_object__c_ptr !! Access to internal C pointer #endif @@ -107,7 +107,7 @@ function fckit_object__c_ptr(this) use, intrinsic :: iso_c_binding, only: c_ptr type(c_ptr) :: fckit_object__c_ptr class(fckit_object), intent(in) :: this - fckit_object__c_ptr = this%CPTR_PGIBUG_A + fckit_object__c_ptr = this%cpp_object_ptr end function subroutine reset_c_ptr(this,cptr,deleter) @@ -124,14 +124,14 @@ subroutine reset_c_ptr(this,cptr,deleter) endif #endif if( present(cptr) ) then - this%CPTR_PGIBUG_A = cptr + this%cpp_object_ptr = cptr if( present(deleter) ) then this%deleter = deleter else this%deleter = c_null_funptr endif else - this%CPTR_PGIBUG_A = c_null_ptr + this%cpp_object_ptr = c_null_ptr this%deleter = c_null_funptr endif end subroutine @@ -140,7 +140,7 @@ function is_null(this) use, intrinsic :: iso_c_binding, only: c_associated logical :: is_null class(fckit_object) :: this - if( c_associated( this%CPTR_PGIBUG_A ) ) then + if( c_associated( this%cpp_object_ptr ) ) then is_null = .False. else is_null = .True. @@ -151,14 +151,14 @@ logical function equal(obj1,obj2) use fckit_c_interop_module, only : c_ptr_compare_equal class(fckit_object), intent(in) :: obj1 class(fckit_object), intent(in) :: obj2 - equal = c_ptr_compare_equal(obj1%CPTR_PGIBUG_A,obj2%CPTR_PGIBUG_A) + equal = c_ptr_compare_equal(obj1%cpp_object_ptr,obj2%cpp_object_ptr) end function logical function not_equal(obj1,obj2) use fckit_c_interop_module, only : c_ptr_compare_equal class(fckit_object), intent(in) :: obj1 class(fckit_object), intent(in) :: obj2 - if( c_ptr_compare_equal(obj1%CPTR_PGIBUG_A,obj2%CPTR_PGIBUG_A) ) then + if( c_ptr_compare_equal(obj1%cpp_object_ptr,obj2%cpp_object_ptr) ) then not_equal = .False. else not_equal = .True. @@ -170,14 +170,14 @@ subroutine final( this ) use fckit_c_interop_module, only : fckit_c_deleter_interface class(fckit_object), intent(inout) :: this procedure(fckit_c_deleter_interface), pointer :: deleter - if( c_associated( this%CPTR_PGIBUG_A ) ) then + if( c_associated( this%cpp_object_ptr ) ) then if( c_associated( this%deleter ) ) then call c_f_procpointer( this%deleter, deleter ) - call deleter( this%CPTR_PGIBUG_A ) - this%CPTR_PGIBUG_A = c_null_ptr + call deleter( this%cpp_object_ptr ) + this%cpp_object_ptr = c_null_ptr endif endif - this%CPTR_PGIBUG_A = c_null_ptr + this%cpp_object_ptr = c_null_ptr end subroutine FCKIT_FINAL subroutine fckit_object_final_auto( this ) diff --git a/src/fckit/module/fckit_owned_object.F90 b/src/fckit/module/fckit_owned_object.F90 index 8fd5c3d..67ef300 100644 --- a/src/fckit/module/fckit_owned_object.F90 +++ b/src/fckit/module/fckit_owned_object.F90 @@ -88,10 +88,6 @@ module fckit_owned_object_module procedure, public :: consumed end type -interface fckit_object - module procedure fckit_owned_object_constructor -end interface - !======================================================================== private :: c_ptr @@ -157,14 +153,14 @@ subroutine fckit_owned_object__delete( this ) procedure(fckit_c_deleter_interface), pointer :: deleter FCKIT_WRITE_LOC FCKIT_WRITE_DEBUG "fckit_owned_object__delete" - if( c_associated( this%CPTR_PGIBUG_A ) ) then + if( c_associated( this%cpp_object_ptr ) ) then if( c_associated( this%deleter ) ) then call c_f_procpointer( this%deleter, deleter ) - call deleter( this%CPTR_PGIBUG_A ) - this%CPTR_PGIBUG_A = c_null_ptr + call deleter( this%cpp_object_ptr ) + this%cpp_object_ptr = c_null_ptr endif endif - this%CPTR_PGIBUG_A = c_null_ptr + this%cpp_object_ptr = c_null_ptr end subroutine subroutine fckit_owned_object__final(this) @@ -234,7 +230,7 @@ subroutine assignment_operator(this,other) subroutine attach(this) class(fckit_owned_object), intent(inout) :: this if( .not. this%is_null() ) then - call fckit__Owned__attach(this%CPTR_PGIBUG_A) + call fckit__Owned__attach(this%cpp_object_ptr) FCKIT_WRITE_LOC FCKIT_WRITE_DEBUG "attach" endif @@ -243,7 +239,7 @@ subroutine attach(this) subroutine detach(this) class(fckit_owned_object), intent(inout) :: this if( .not. this%is_null() ) then - call fckit__Owned__detach(this%CPTR_PGIBUG_A) + call fckit__Owned__detach(this%cpp_object_ptr) FCKIT_WRITE_LOC FCKIT_WRITE_DEBUG "detach" endif @@ -255,7 +251,7 @@ function owners(this) if( this%is_null() ) then owners = 0 else - owners = fckit__Owned__owners(this%CPTR_PGIBUG_A) + owners = fckit__Owned__owners(this%cpp_object_ptr) endif end function @@ -292,15 +288,6 @@ subroutine assignment_operator_hook(this, other) end subroutine -subroutine bad_cast(message) - character(len=*), optional :: message - if( present(message) ) then - write(0,'("ERROR: bad_cast -- ",A)') message - else - write(0,'("ERROR: bad cast")') - endif -end subroutine - subroutine consumed(this) class(fckit_owned_object), intent(in) :: this type(fckit_owned_object) :: consumed_object @@ -309,25 +296,11 @@ subroutine consumed(this) end subroutine - - -function fckit_owned_object_constructor( cptr, deleter ) result(this) - use, intrinsic :: iso_c_binding, only : c_ptr, c_funptr - type(fckit_owned_object) :: this - type(c_ptr) :: cptr - type(c_funptr), optional :: deleter - if( present(deleter) ) then - call this%reset_c_ptr( cptr, deleter ) - else - call this%reset_c_ptr( cptr ) - endif -end function - function fckit_owned_object__c_ptr(this) use, intrinsic :: iso_c_binding, only: c_ptr type(c_ptr) :: fckit_owned_object__c_ptr class(fckit_owned_object), intent(in) :: this - fckit_owned_object__c_ptr = this%CPTR_PGIBUG_A + fckit_owned_object__c_ptr = this%cpp_object_ptr end function @@ -335,7 +308,7 @@ function is_null(this) use, intrinsic :: iso_c_binding, only: c_associated logical :: is_null class(fckit_owned_object) :: this - if( c_associated( this%CPTR_PGIBUG_A ) ) then + if( c_associated( this%cpp_object_ptr ) ) then is_null = .False. else is_null = .True. @@ -346,14 +319,14 @@ logical function equal(obj1,obj2) use fckit_c_interop_module, only : c_ptr_compare_equal class(fckit_owned_object), intent(in) :: obj1 class(fckit_owned_object), intent(in) :: obj2 - equal = c_ptr_compare_equal(obj1%CPTR_PGIBUG_A,obj2%CPTR_PGIBUG_A) + equal = c_ptr_compare_equal(obj1%cpp_object_ptr,obj2%cpp_object_ptr) end function logical function not_equal(obj1,obj2) use fckit_c_interop_module, only : c_ptr_compare_equal class(fckit_owned_object), intent(in) :: obj1 class(fckit_owned_object), intent(in) :: obj2 - if( c_ptr_compare_equal(obj1%CPTR_PGIBUG_A,obj2%CPTR_PGIBUG_A) ) then + if( c_ptr_compare_equal(obj1%cpp_object_ptr,obj2%cpp_object_ptr) ) then not_equal = .False. else not_equal = .True. @@ -367,7 +340,7 @@ subroutine reset_c_ptr(this,cptr,deleter) type(c_ptr), optional :: cptr type(c_funptr), optional :: deleter if( present(cptr) ) then - this%CPTR_PGIBUG_A = cptr + this%cpp_object_ptr = cptr call this%attach() if( present(deleter) ) then @@ -377,7 +350,7 @@ subroutine reset_c_ptr(this,cptr,deleter) endif else - this%CPTR_PGIBUG_A = c_null_ptr + this%cpp_object_ptr = c_null_ptr this%deleter = c_null_funptr endif diff --git a/src/fckit/module/fckit_refcount.F90 b/src/fckit/module/fckit_refcount.F90 index 4b18a26..269e4e0 100644 --- a/src/fckit/module/fckit_refcount.F90 +++ b/src/fckit/module/fckit_refcount.F90 @@ -110,6 +110,7 @@ subroutine allocate_fckit_external(refcount,shared_ptr) class(fckit_refcount), pointer, intent(inout) :: refcount class(*), target, intent(in) :: shared_ptr allocate( fckit_refcount_external::refcount ) + FCKIT_SUPPRESS_UNUSED( shared_ptr ) end subroutine function fckit_external() result(funptr) diff --git a/src/fckit/module/fckit_resource.F90 b/src/fckit/module/fckit_resource.F90 index fde46bd..c9dde43 100644 --- a/src/fckit/module/fckit_resource.F90 +++ b/src/fckit/module/fckit_resource.F90 @@ -102,7 +102,7 @@ subroutine resource_get_int64(resource_str,default_value,value) integer(c_int64_t), intent(in) :: default_value integer(c_int64_t), intent(out) :: value integer(c_int32_t) :: error_code - error_code = fckit__resource_int64(c_str(resource_str),default_value,value) + error_code = int(fckit__resource_int64(c_str(resource_str),default_value,value),c_int32_t) end subroutine subroutine resource_get_real32(resource_str,default_value,value) diff --git a/src/fckit/module/fckit_shared_object.F90 b/src/fckit/module/fckit_shared_object.F90 index f305bef..1d0eb8d 100644 --- a/src/fckit/module/fckit_shared_object.F90 +++ b/src/fckit/module/fckit_shared_object.F90 @@ -40,7 +40,10 @@ module fckit_shared_object_module procedure, public :: reset_c_ptr - !procedure, public :: c_ptr => fckit_shared_object_c_ptr +#if !PGIBUG_ATLAS_197_DEBUG + procedure, public :: c_ptr => fckit_shared_object_c_ptr +#endif + procedure, private :: fckit_shared_object_c_ptr procedure, public :: is_null @@ -70,6 +73,7 @@ module fckit_shared_object_module CONTAINS !======================================================================== +#if FCKIT_FINAL_NOT_INHERITING FCKIT_FINAL subroutine fckit_shared_object__final_auto(this) type(fckit_shared_object), intent(inout) :: this #if FCKIT_FINAL_DEBUGGING @@ -80,6 +84,7 @@ FCKIT_FINAL subroutine fckit_shared_object__final_auto(this) #endif FCKIT_SUPPRESS_UNUSED( this ) end subroutine +#endif function shared_ptr_cast(this) result(success) class(fckit_shared_object) :: this @@ -134,7 +139,7 @@ function fckit_shared_object_c_ptr(this) result(cptr) use, intrinsic :: iso_c_binding, only : c_ptr type(c_ptr) :: cptr class(fckit_shared_object) :: this - cptr = this%CPTR_PGIBUG_B + cptr = this%shared_object_%CPTR_PGIBUG_A end function end module diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3779a6a..f312b67 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -51,6 +51,11 @@ add_fctest( TARGET fckit_test_configuration SOURCES test_configuration.F90 CONDITION HAVE_ECKIT LIBS fckit) +if( TEST fckit_test_configuration ) + if( NOT CMAKE_VERSION VERSION_LESS 3.15 ) # support for COMPILE_LANG_AND_ID generator expression + target_compile_options( fckit_test_configuration PRIVATE $<$:-Wno-uninitialized> ) + endif() +endif() add_fctest( TARGET fckit_test_configuration_fails LINKER_LANGUAGE Fortran diff --git a/src/tests/test_configuration.F90 b/src/tests/test_configuration.F90 index 2358b66..692a4e4 100644 --- a/src/tests/test_configuration.F90 +++ b/src/tests/test_configuration.F90 @@ -195,6 +195,7 @@ write(0,*) "~~~~~~~~~~~~~~ SCOPE BEGIN ~~~~~~~~~~~~~~~" + allocate( character(len=256) :: json ) json='{"records":['//& & '{"name":"Joe", "age":30},'//& & '{"name":"Alison","age":43}' //& @@ -241,8 +242,8 @@ type(fckit_Configuration) :: config type(fckit_Configuration), allocatable :: records(:) type(fckit_Configuration) :: location - character (len=:), allocatable :: name, company, street, city - character (len=:), allocatable :: variables(:) + character(len=:), allocatable :: name, company, street, city + character(len=:), allocatable :: variables(:) integer :: age integer :: jrec logical :: logval diff --git a/src/tests/test_configuration_fortcode.F90 b/src/tests/test_configuration_fortcode.F90 index 7007221..2a04d0a 100644 --- a/src/tests/test_configuration_fortcode.F90 +++ b/src/tests/test_configuration_fortcode.F90 @@ -7,10 +7,10 @@ ! does it submit to any jurisdiction. function c_get_a( conf_cptr ) result(a) bind(c) - use, intrinsic :: iso_c_binding, only : c_ptr + use, intrinsic :: iso_c_binding, only : c_ptr, c_int use fckit_configuration_module implicit none - integer :: a + integer(c_int) :: a type(c_ptr), value :: conf_cptr type(fckit_configuration) :: conf write(0,*) "c_get_a ..." diff --git a/src/tests/test_downstream_fctest/CMakeLists.txt b/src/tests/test_downstream_fctest/CMakeLists.txt index 7734cbe..d95656b 100644 --- a/src/tests/test_downstream_fctest/CMakeLists.txt +++ b/src/tests/test_downstream_fctest/CMakeLists.txt @@ -13,6 +13,11 @@ if( HAVE_TESTS ) if( CMAKE_TOOLCHAIN_FILE ) list( APPEND _test_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" ) endif() + foreach( lang C CXX Fortran ) + if( CMAKE_${lang}_COMPILER ) + list( APPEND _test_args "-DCMAKE_${lang}_COMPILER=${CMAKE_${lang}_COMPILER}" ) + endif() + endforeach() add_test( NAME fckit_test_downstream_fctest COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-downstream.sh ${_test_args} ) diff --git a/src/tests/test_downstream_fypp/CMakeLists.txt b/src/tests/test_downstream_fypp/CMakeLists.txt index 60aaf83..b23adca 100644 --- a/src/tests/test_downstream_fypp/CMakeLists.txt +++ b/src/tests/test_downstream_fypp/CMakeLists.txt @@ -13,6 +13,11 @@ if( HAVE_TESTS AND HAVE_ECKIT ) if( CMAKE_TOOLCHAIN_FILE ) list( APPEND _test_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" ) endif() + foreach( lang C CXX Fortran ) + if( CMAKE_${lang}_COMPILER ) + list( APPEND _test_args "-DCMAKE_${lang}_COMPILER=${CMAKE_${lang}_COMPILER}" ) + endif() + endforeach() add_test( NAME fckit_test_downstream_fypp COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-downstream.sh ${_test_args} ) diff --git a/src/tests/test_fypp.fypp b/src/tests/test_fypp.fypp index abcc974..765700f 100644 --- a/src/tests/test_fypp.fypp +++ b/src/tests/test_fypp.fypp @@ -37,6 +37,15 @@ TEST( allocate_different_types ) ${ftype}$, allocatable :: var_${dtype}$_${rank}$(${dim[rank]}$) #:endfor #:endfor + + #:for rank in ranks + #:for dtype,ftype in types + if( allocated( var_${dtype}$_${rank}$ ) ) then + write(0,*) "suppress warning" + endif + #:endfor + #:endfor + END_TEST TEST( test_macros ) @@ -52,4 +61,4 @@ TEST( test_macros ) FCTEST_CHECK_EQUAL(err_code, 1) END_TEST -END_TESTSUITE \ No newline at end of file +END_TESTSUITE diff --git a/src/tests/test_mpi.F90 b/src/tests/test_mpi.F90 index 0eb097e..999f7cc 100644 --- a/src/tests/test_mpi.F90 +++ b/src/tests/test_mpi.F90 @@ -103,7 +103,7 @@ type(fckit_mpi_comm) :: comm real(c_double) :: real64, res_real64, real64_r1(2), res_real64_r1(2) real(c_float) :: real32, res_real32, real32_r2(3,2), res_real32_r2(3,2) - integer(c_int32_t) :: int32, res_int32, int32_r3(4,3,2), res_int32_r3(4,3,2), j + integer(c_int32_t) :: int32, res_int32, res_int32_r3(4,3,2), j integer(c_long) :: int64, res_int64, int64_r4(4,3,2,2), res_int64_r4(4,3,2,2), check_prod, check_sum FCKIT_SUPPRESS_UNUSED( real64_r1 ) @@ -662,7 +662,7 @@ implicit none type(fckit_mpi_comm) :: world ! a handle for the world comm type(fckit_mpi_comm) :: split ! a handle for the split comm - integer :: i, j + integer :: i world = fckit_mpi_comm("world") if( mod(world%size(),2) == 0 ) then