Making Cassandra friendly for the Absoft Compiler

  • Zarathustra
  • Zarathustra's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 11 months ago - 6 years 11 months ago #342 by Zarathustra
Here is a quick fix to the random number generator routine that makes Cassandra ready to use with the Absoft compiler. While Cassandra is ready to go for the gfortran, intel, and one other compiler which I forget, it stumbles with the Absoft compiler.

The following modifies the Function rranf() so that it works with the Absoft compiler, and there is no loss in usability with gfortran, I don't know about the other two. Hopefully this small modification can be added to future versions of Cassandra.

from module random_generators.f90

FUNCTION rranf()

! Returns a random number over the interval 0 to 1.

USE Type_Definitions, ONLY : DP
USE File_Names, ONLY : logunit

IMPLICIT NONE

REAL(DP) :: rranf

INTEGER (KIND= 8 ) :: b

***************** BEGIN MODIFICATION HERE**************************
INTEGER (KIND= 8 ) :: ia,ib,ic,id,ie

! The negative integers throw Absoft for a loop, however assigning them to variable names fixes it.

ia = -2
ib = -512
ic = -4096
id = -131072
ie = -8388608

!note ia, ib,ic,id, and ie show up in s1,s2,s3,s4 and s5

b = ISHFT( IEOR( ISHFT(s1,1), s1), -53)
s1 = IEOR( ISHFT( IAND(s1,ia), 10), b)
b = ISHFT( IEOR( ISHFT(s2,24), s2), -50)
s2 = IEOR( ISHFT( IAND(s2,ib), 5), b)
b = ISHFT( IEOR( ISHFT(s3,3), s3), -23)
s3 = IEOR( ISHFT( IAND(s3,ic), 29), b)
b = ISHFT( IEOR( ISHFT(s4,5), s4), -24)
s4 = IEOR( ISHFT( IAND(s4,id), 23), b)
b = ISHFT( IEOR( ISHFT(s5,3), s5), -33)
s5 = IEOR( ISHFT( IAND(s5,ie), 8 ), b)

***************** END MODIFICATION HERE**************************

! pconst is the reciprocal of (2^64 - 1)
rranf = IEOR( IEOR( IEOR( IEOR(s1,s2), s3), s4), s5) *5.4210108624275221E-20_DP + 0.5_DP

IF(rranf .GE. 1.0_DP) WRITE(logunit,*) 'rranf = 1.0'

END FUNCTION rranf

I have attached the modified random_generators.f90 file as a *.txt since it doesn't want me to upload a *.f90 file.

May it find some use,

Zarathustra
Attachments:
Last Edit: 6 years 11 months ago by Zarathustra. Reason: the number 8 showed up as a cool smiley face, I think i fixed it
The following user(s) said Thank You: ejmaginn

Please Log in to join the conversation.

More
6 years 11 months ago #358 by ejmaginn
Thanks for the suggestion. We don't have this compiler and so can't test this right now. I am glad you have posted this, however, since it should be useful to others. Once we can test this, we will consider adding it to the main release. Thanks again.

Please Log in to join the conversation.

Time to create page: 0.104 seconds