incorrect result with this_image() inside an array constructor

Damian Rouson damian@sourceryinstitute.org
Sun Jun 14 17:39:00 GMT 2015


Gfortran developers,

I’m trying to sort out whether behavior that Arjen Markus reported on the OpenCoarrays mailing list is a front-end bug or a library bug.   A slightly edited version of his code is below.

On the one hand, I think this might be a gfortran front-end problem because simply storing the result of this_image() in an integer variable eliminates the problem.  On the other hand, it might be a library problem because the problem occurs when linking to libcaf_mpi.a, but not when linking to libcaf_single.a.  I’ll send this to the gfortran developers for further advice.  In the meantime, please try the workaround of storing this_image() in an integer variable before using the result in the array constructor.  If it’s a library issue, then it will probably be a few days before we have a chance to sort it out so I hope the workaround is sufficient for now.

Damian 

$ cat initreal.f90 
  implicit none
  integer i,j
  real  array(1)[*]

  j = this_image()
  array = [ (j * i, i = 1,1) ]  ! This gives the correct array
  print *,'Image number stored in j: ', this_image(), array
  
  array = [ (this_image() * i, i = 1,1) ]  ! This gives a zero array
  print *,'Image number not stored : ', this_image(), array

end

$ gfortran  -fcoarray=single initreal.f90 -lcaf_single

$ ./a.out
 Image number stored in j:            1   1.00000000    
 Image number not stored :            1   1.00000000    

$ mpif90 -fcoarray=lib initreal.f90 -lcaf_mpi

$ mpirun -np 1 ./a.out
 Image number stored in j:            1   1.00000000    
 Image number not stored :            1   0.00000000

$ mpif90 -fcoarray=single initreal.f90 -lcaf_single

$ mpirun -np 1 ./a.out
 Image number stored in j:            1   1.00000000    
 Image number not stored :            1   1.00000000     



________________________________
Damian Rouson, Ph.D., P.E.
Founder & President, Sourcery, Inc.
510-600-2992 (mobile)
http://www.sourceryinstitute.org
http://rouson.youcanbook.me



More information about the Fortran mailing list