Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

F2018's RANDOM_INIT for gfortran

368 views
Skip to first unread message

steve kargl

unread,
Jan 12, 2018, 8:32:22 PM1/12/18
to
To gfortran users,

I recently undertook the task of implementing RANDOM_INIT for
gfortran. After two weekends and several week nights, I finally
have a version that I believe conforms to the F2018 standard, but
there are a few choices that I made due to what I deem to be an
inadequate specification.


TL;DR version: I estimate that I have volunteered ~30 hours on
this effort. The patch will be made available upon the verified
donation of $600.00 USD to local charities. By local, I mean
charities in your own backyard.


For those that have not read the F2018 Fortran Standard, the
interface is

IMPURE SUBROUTINE RANDOM_INIT(REPEATABLE, IMAGE_DISTINCT)
LOGICAL, INTENT(IN) :: REPEATABLE
LOGICAL, INTENT(IN) :: IMAGE_DISTINCT
END SUBROUTINE RANDOM_INIT

IMAGE_DISTINCT is clearly meant for a program that uses co-arrays
where upon execution multiple images are instantiated. If a program
does not use co-arrays or only a single image is instantiated, then
IMAGE_DISTINCT is irrelevant. There are four combinations of
REPEATABLE and IMAGE_DISTINCT. The behavior is as follows:

CALL RANDOM_INIT(.TRUE., .TRUE.)

The sequence of random numbers is repeatable. If the program is
compiled with -fcoarray=lib and multiple images are instantiated,
then each image accesses a repeatable distinct sequence of random
numbers. Technically, the Standard states that a distinct seed is
used in each image (with the tacit assumption that the sequences
are distinct, but this is not guaranteed). Also, the repeatibility
is guaranteed for the currently executing image. Rerunning the
executable does not require the same distinct seeds, but I have
chose to use the same seeds.

CALL RANDOM_INIT(.FALSE., .FALSE.)
CALL RANDOM_INIT(.FALSE., .TRUE.)

The sequence of random numbers is determined from a processor-dependent
seed. On each execution of the executable, different seeds will be
used. For -fcoarray=lib and multiple instantiated images, each image
will use its own processor-dependent seed. In other words, the two
calls have identical behavior.

CALL RANDOM_INIT(.TRUE., .FALSE.)

For a program compiled without the -fcoarray= option or with
-fcoarray=single, a single image is instantiated. The sequence of
random numbers is repeatable via multiple calls duration of the
image. I have chosen to have repeatibility across execution of the
program. If the executable causes multiple images to be instantiated,
then image_distinct=.false. in one image cannot affect the sequence of
random numbers in another image. As gfortran gives each image its own
independent PRNG, this condition is automatically satisfied. In fact,
I have chosen that the same seed is used in all images, so each image
accesses its own private copy of the same sequence of random numbers.

$20 / hour is cheap.

--
steve

baf

unread,
Jan 12, 2018, 11:35:29 PM1/12/18
to
On 1/12/2018 5:32 PM, steve kargl wrote:
> To gfortran users,
>
> I recently undertook the task of implementing RANDOM_INIT for
> gfortran. After two weekends and several week nights, I finally
> have a version that I believe conforms to the F2018 standard, but
> there are a few choices that I made due to what I deem to be an
> inadequate specification.
>
> $20 / hour is cheap.
>
Thank you. I very much appreciate having this routine available as it
is much more convenient than the one I currently use. Also thanks for
your continuing work on providing patches to gfortran.

Vishnu

unread,
Jun 8, 2018, 7:09:57 AM6/8/18
to
On Saturday, 13 January 2018 01:32:22 UTC, steve kargl wrote:

>
> CALL RANDOM_INIT(.FALSE., .FALSE.)
> CALL RANDOM_INIT(.FALSE., .TRUE.)
>
> The sequence of random numbers is determined from a processor-dependent
> seed. On each execution of the executable, different seeds will be
> used. For -fcoarray=lib and multiple instantiated images, each image
> will use its own processor-dependent seed. In other words, the two
> calls have identical behavior.
>


In the case of CALL RANDOM_INIT(.FALSE., .TRUE.), shouldn't it be that every execution results in a dfferent sequence of random numbers, but within an execution, every image should see the same sequence?

Vishnu

unread,
Jun 8, 2018, 7:18:24 AM6/8/18
to
Sorry, I meant that in the case of CALL RANDOM_INIT(.FALSE., .FALSE.); because the images should NOT be distinct. No?

Anton Shterenlikht

unread,
Jun 8, 2018, 8:15:03 AM6/8/18
to
UK comments on DIS include 3 editorial
and technical changes on RANDOM_INIT
for discussion at J3/WG5 meeting next week:

https://j3-fortran.org/doc/year/18/18-161.pdf

So the description is likely to change.

Anton

steve kargl

unread,
Jun 8, 2018, 11:03:43 AM6/8/18
to
In the mean time, I have committed my implementation
of RANDOM_INIT to the gfortran source code repository.
The standard as written in the current draft does not
place any requirement on the .false., .false. case.

--
steve

Vishnu

unread,
Jun 9, 2018, 1:44:32 AM6/9/18
to
On Fri, 2018-06-08 at 15:03 +0000, steve kargl wrote:
>
> The standard as written in the current draft does not
> place any requirement on the .false., .false. case.
>

I think I disagree:

Ref: https://www.lrz.de/services/software/programmierung/fortran/ISO-IECJTC
1-SC22-WG5_N2145_Summary_of_Fortran_2018.pdf

Section: 5.14

repeatable:
If it has the value false, the seed is set to a processor-dependent,
unpredictably different value on each call.

image_distinct:
If it has the value false, the value to which the seed is set does not
depend on which image calls random init.


A .FALSE. logical input to the IMAGE_DISTINCT argument seems to require that
every image gets a random number sequence with the same seed.
And if this is under a .FALSE. logical input to the REPEATABLE
argument, then this seed must be different each time the executable is run.

So I do think the (.FALSE., .FALSE.) case is distinct from the (.FALSE.,
.TRUE.) case.

michael...@compuserve.com

unread,
Jul 6, 2018, 12:28:32 PM7/6/18
to
Those of you interested in random_init might like to know that at the recent standardization committee meeting it was decided to make a key change, namely to require each image to have its own seed.
Some do not like this - wanting to have a single RNG that each
image can access (only one at once). Others think this is fine on a small
shared-memory system but less so on a really big machine. The latter won.

Regards,

Mike Metcalf

Michael Siehl

unread,
Jul 6, 2018, 3:24:08 PM7/6/18
to
Thanks for sharing, it is also explained in more detail by Steve Lionel, here:
https://software.intel.com/en-us/blogs/2018/06/23/doctor-fortran-in-the-end-is-nigh

Personally, and within my F2008 programming, I did tend to prefer features that do not inherently require (unnecessary) synchronization between coarray images. (But this has already changed with the advent of coarray teams with gfortran/OpenCoarrays). My first notion was still to agree with that decision.

robin....@gmail.com

unread,
Jul 6, 2018, 10:09:04 PM7/6/18
to
If you want something you have complete control over and
which is entirely predictable, you can't do better than
George Marsaglia's PRNGs that were posted in this NG.

Jack Potter

unread,
Jul 7, 2018, 2:34:08 AM7/7/18
to
U.S.A /CA Call//Text/ WhatsApp:+1 8304848039 Vicodin, Valium, Hydrocodone, Adderal, Xanax, Steroids,Vicodin, Valium, Hydrocodone, Adderal, Xanax, Steroids

Order Original pain medications, anxiety management medications and
injections, ED pills and Cough Syrups and many others at attractive prices.
email at:

Cal USA :+18304848039

SHIPPING:
Stealth Package
- Vacuum sealed thick plastic
- Return address.
- Express Delivery with tracking

Shipping time varies for each country.
But all deliveries are done within 1 to 3 business days.
Delivery guaranteed!!

Xanax 1 mg ( blue Ksalol)
Xanax 1 mg Upjohn footbals
Xanax 2 mg ( Pfizer LongBars)
Xanax Alprazolam 1mg Parke Davis
AYURVEDIC UREA GROW TALLER HERB, LIQUID AND POWDER.
Calypsol 500mg/10ml, Anesket 1000mg/10ml
Medical Marijuana
Oxycodone 30mg
Oxycontin 40mg
Roxicodone 30mg
Diazepam Valium 10mg
Subutex 8mg
Suboxone 8mg
Ritalin 40mg
Adderall 30mg
Mandrax (Quaalude) 300mg
Tramadol 100mg
Percocet 10mg
Oxynorm 20mg
Vicodin 500mg
Modafinil Nootropics
Ecstasy (Blue Androids)
Ketamine
MDMA
LSD
Fentalyn patches
Nembutal
Klonopin
Ativan
KCN
Seconal
Dilaud , id
AMBIEN
Oxycontin
Percocet
Roxicodon , e
Valium
Adderall
Norco
Hydrocodone
suboxone
truvada 200 mg-300 mg
subutex
watson 540
WATSON 325 10MG
WATSON 853 10MG
Norco
Ambien
DNP (2,4-Dinitrophenol) 100 mg Capsules
METHADONE 10MG, 40MG WAFERS
ACTAVIS PROMETHAZINE
Quaaludes - Methaquallone pills
Growth Hormones
Anabolic Steroid

Here below is the list of oil we have in stock to offer
( Shatter )
(wax )
( Hash )
( afghani oil )
(organic hemp o il =)
( BHO )
(Crumble )
Here below are the strains we have to offer
( Og kush )
( Sour diesel )
( white widow )
( super silver haze )
( jack herer )
( Alaskan thunder fuck )
( green crack = )
( Alien trainwreck )
( pineapple express )
( LSD )
( Afghani kush )
(G13 ) a
(Ak 47)
(Blueberry Kush )

Delivery & quality Guaranteed 100%.
Express Delivery Available with UPS,FedEx,
Tracking numbers available with references.
Shipping secure and discreet
Delivery time. -1 day within U.S.A 2 days out of U.S
Payment Method:By Western Union, Bitcoin, Moneygram, Paypal for bulk order, fast delivery.



U.S.A /CA Call//Text:+1 8304848039


Vishnu

unread,
Jul 7, 2018, 9:45:17 AM7/7/18
to
Steve, it would seem that I was right. The new language in the standard, with regards to IMAGE_DISTINCT says:

"If it has the value true, the seeds on the images of the current team that use separate random number generators and on the sets of images of the current team that use common random number generators are set to values that are all different. If it has the value false, these seeds are all set to the same value"

steve kargl

unread,
Jul 7, 2018, 12:48:57 PM7/7/18
to
Vishnu wrote:

> On Saturday, 9 June 2018 05:44:32 UTC, Vishnu wrote:
>> On Fri, 2018-06-08 at 15:03 +0000, steve kargl wrote:
>> >
>> > The standard as written in the current draft does not
>> > place any requirement on the .false., .false. case.
>> >
>>
>> I think I disagree:
>>
>> Ref: https://www.lrz.de/services/software/programmierung/fortran/ISO-IECJTC
>> 1-SC22-WG5_N2145_Summary_of_Fortran_2018.pdf
>>
>> Section: 5.14
>>
>> repeatable:
>> If it has the value false, the seed is set to a processor-dependent,
>> unpredictably different value on each call.
>>
>> image_distinct:
>> If it has the value false, the value to which the seed is set does not
>> depend on which image calls random init.
>>
>>
>> A .FALSE. logical input to the IMAGE_DISTINCT argument seems to require that
>> every image gets a random number sequence with the same seed.
>> And if this is under a .FALSE. logical input to the REPEATABLE
>> argument, then this seed must be different each time the executable is run.
>>
>> So I do think the (.FALSE., .FALSE.) case is distinct from the (.FALSE.,
>> .TRUE.) case.
>
> Steve, it would seem that I was right. The new language in the standard, with regards to IMAGE_DISTINCT says:

You were neither right nor wrong with respect to the language in the previous draft
of the F2018 standard. You gave one interpretation of that language and I gave
another interpretation. If the previous draft had been clear, then there would not
have been a change in the language of the Standard. It seems that your interpretation
was the intent of the author of RANDOM_INIT. It is also clear that J3/WG5 agreed that
the previous draft was subject to interpretations that did not align with that author's intent.

--
steve
0 new messages