@@ -36,7 +36,7 @@ module opencoarrays
36
36
#elif defined(COMPILER_LACKS_C_SIZEOF_ASSUMED_RANK)
37
37
use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_ptrdiff_t
38
38
#else
39
- use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_bool,c_funloc,c_ptrdiff_t,c_sizeof
39
+ use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_float, c_double,c_int32_t,c_bool,c_funloc,c_ptrdiff_t,c_sizeof
40
40
#endif
41
41
implicit none
42
42
@@ -240,8 +240,9 @@ subroutine caf_finalize(argc, argv) bind(C,name="_gfortran_caf_finalize")
240
240
! PREFIX(registernc) (void* mem,size_t mem_size)
241
241
242
242
subroutine opencoarrays_registernc (mem ,mem_size ) bind(C,name= " _gfortran_caf_registernc" )
243
+ import :: c_ptr,c_ptrdiff_t,c_int
243
244
type (c_ptr), intent (in ), value :: mem
244
- integer (c_ptrdiff_t), intent (in ) :: mem_size
245
+ integer (c_ptrdiff_t), value, intent (in ) :: mem_size
245
246
end subroutine
246
247
247
248
! C function signature from ../mpi/mpi_caf.c:
@@ -268,7 +269,7 @@ subroutine opencoarrays_co_reduce(a, opr, opr_flags, result_image, stat, errmsg,
268
269
#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
269
270
bind(C,name= " _caf_extensions_co_reduce" )
270
271
#else
271
- bind(C,name= " _gfortran_extensions_co_reduce " )
272
+ bind(C,name= " _gfortran_caf_co_reduce " )
272
273
#endif
273
274
use iso_c_binding, only : c_ptr,c_funptr,c_int,c_char
274
275
type (c_ptr), intent (in ), value :: a
@@ -364,8 +365,7 @@ function opencoarrays_this_image(coarray) bind(C,name="_gfortran_caf_this_image"
364
365
365
366
! C function signature from ../mpi/mpi_caf.c:
366
367
! int PREFIX (num_images) (int, int);
367
- ! function opencoarrays_num_images(coarray,dim_) bind(C,name="_gfortran_caf_num_images") result(num_images_)
368
- function opencoarrays_num_images (coarray ,dim_ ) bind(C,name= " _caf_extensions_num_images" ) result(num_images_)
368
+ function opencoarrays_num_images (coarray ,dim_ ) bind(C,name= " _gfortran_caf_num_images" ) result(num_images_)
369
369
import :: c_int
370
370
integer (c_int), value, intent (in ) :: coarray,dim_
371
371
integer (c_int) :: num_images_
@@ -570,8 +570,8 @@ function c_sizeof(mold) result(c_size_of_mold)
570
570
! _________________________________________________________________________________
571
571
572
572
subroutine accelerate (a )
573
- real (c_double ), intent (in ), contiguous :: a(..)
574
- call opencoarrays_registernc(c_loc(a),size (a) * c_sizeof(a))
573
+ real (c_float ), intent (in ), contiguous, target :: a(..)
574
+ call opencoarrays_registernc(c_loc(a),c_sizeof(a))
575
575
end subroutine
576
576
577
577
subroutine co_reduce_c_int (a , opr , result_image , stat , errmsg )
@@ -877,23 +877,27 @@ subroutine co_sum_c_int(a,result_image,stat,errmsg)
877
877
end subroutine
878
878
879
879
! Return the image number (MPI rank + 1)
880
- function this_image () result(image_num)
881
- use mpi, only : MPI_Comm_rank
882
- integer (c_int) :: image_num,ierr
883
- ! image_num = opencoarrays_this_image(unused)
884
- call MPI_Comm_rank(CAF_COMM_WORLD,image_num,ierr)
885
- if (ierr/= 0 ) call error_stop
886
- image_num = image_num + 1
887
- end function
880
+ function this_image () result(image_num)
881
+ #ifndef COMPILER_PROVIDES_MPI
882
+ use mpi, only : MPI_Comm_rank
883
+ #endif
884
+ integer (c_int) :: image_num,ierr
885
+ ! image_num = opencoarrays_this_image(unused)
886
+ call MPI_Comm_rank(CAF_COMM_WORLD,image_num,ierr)
887
+ if (ierr/= 0 ) call error_stop
888
+ image_num = image_num + 1
889
+ end function
888
890
889
891
! Return the total number of images
890
- function num_images () result(num_images_)
891
- use mpi, only : MPI_Comm_size
892
- integer (c_int) :: num_images_,ierr
893
- ! num_images_ = opencoarrays_num_images(unused_coarray,unused_scalar)
894
- call MPI_Comm_size(CAF_COMM_WORLD,num_images_,ierr)
895
- if (ierr/= 0 ) call error_stop
896
- end function
892
+ function num_images () result(num_images_)
893
+ #ifndef COMPILER_PROVIDES_MPI
894
+ use mpi, only : MPI_Comm_size
895
+ #endif
896
+ integer (c_int) :: num_images_,ierr
897
+ ! num_images_ = opencoarrays_num_images(unused_coarray,unused_scalar)
898
+ call MPI_Comm_size(CAF_COMM_WORLD,num_images_,ierr)
899
+ if (ierr/= 0 ) call error_stop
900
+ end function
897
901
898
902
! Halt the execution of all images
899
903
subroutine error_stop (stop_code )
0 commit comments