gfortran documentation fix: replace getpid() with THIS_IMAGE() in init_random_seed()

Damian Rouson damian@sourceryinstitute.org
Mon May 16 23:30:00 GMT 2016


All,

Would THIS_IMAGE() be a reasonable, standard-conforming replacement for 
the gfortran extension “getpid()” in the following documentation page?

https://gcc.gnu.org/onlinedocs/gfortran/RANDOM_005fSEED.html

>From the comment a few lines above the call, it seems the primary motivation 
for generating a process ID (PID) is for each parallel instance to receive a 
unique integer result.  In my very limited testing with gfortran/OpenCoarrays
in shared memory on Linux and OS X, the getpid() result differs from that of 
THIS_IMAGE() by an offset that is constant across all images.  

THIS_IMAGE() might be superior in that it guarantees each image a 
unique result even in distributed memory, which I assume getpid() does 
not guarantee.  If others agree, I’ll submit a documentation patch.  I will
also add a comment suggesting that the user replace THIS_IMAGE() 
with the appropriate procedure for the user’s chosen parallelization 
technology (e.g., MPI process rank or OpenMP thread number). 

Best Regards,
Damian






More information about the Fortran mailing list