The C routine given below implements Marsaglia's KISS RNG. The C code uses unsigned integer arithmetic, so it is not easy to convert to Fortran.
SCC compiles it with no problems, except when /64 is used, in which case it issues a load of spurious error messages.
/* SUPRKISS32.c, period 5*2^1320481*(2^32-1) */
#ifdef LF
#define RANDOM_R8 random_r8_
#define INITKISS32 initkiss32_
#endif
#define BSIZE 41265
static unsigned long Q[BSIZE],indx=BSIZE,
carry=362,xcng=1236789,xs=521288629;
#define CNG ( xcng=69609*xcng+123 ) /*Congruential*/
#define XS ( xs^=xs<<13,xs^=xs>>17,xs^=xs>>5 )/*Xorshift*/
#define SUPR ( indx<BSIZE ? Q[indx++] : refill() ) /*CMWC*/
#define KISS SUPR+CNG+XS
int refill( )
{int i; unsigned long z,h;
for(i=0;i<BSIZE;i++){
h=(carry&1);
z=((Q[i]<<9)>>1)+((Q[i]<<7)>>1)+(carry>>1);
carry=(Q[i]>>23)+(Q[i]>>25)+(z>>31);
Q[i]=~((z<<1)+h);
}
indx=1; return (Q[0]);
}
#ifdef FTN95
extern 'C'
#endif
void RANDOM_R8(double *x, int *n){
int i;
for (i=0; i<*n; i++)x[i] = (KISS)/4294967296.0;
}
#ifdef FTN95
extern 'C'
#endif
void INITKISS32( ){
unsigned long i;
for(i=0;i<BSIZE;i++) Q[i]=CNG+XS;
indx = 0;
}
I have sometimes wondered why SCC insists on treating C code as if it were C++ code, and decorates routine names a la C++, forcing the user to add extern 'C' to enable using the resulting OBJ with Fortran routines. When building 32-bit code, we can use another C compiler.
When building 64-bit code, there is no other C compiler that produces OBJs that slink64 can work with, so bugs in SCC /64 pose an insurmountable obstacle.