Operating System - OpenVMS
1753501 Members
3957 Online
108794 Solutions
New Discussion юеВ

FORTRAN Compile Link Error

 
SOLVED
Go to solution
Joseph Huber_1
Honored Contributor

Re: FORTRAN Compile Link Error

The real problem is not integer overflow for default (kind=4) integers, but the in fact misusing the .OR. operator with integer constants.
I know it is handy to write it in a single concatenation of .or.s, and works in most cases.
The correct usage for integer oring is IOR(int1,int2).
The following is the correct integer ORing and does not need to have prvmsk defined as a 64 bit quantity, which has to be converted back into a 32bit quantity in the sys$... call.
VMS is little endian; on a big-endian system passing a 64bit integer to a routine expecting a 32bit integer would fail!

program test

include '($prvdef)'
integer sys$setprv

integer(kind=4) prvmsk
integer iret

prvmsk=IOR( prv$m_share,IOR(prv$m_tmpmbx,&
IOR(prv$m_sysprv,IOR(prv$m_syslck,&
IOR(prv$m_world,IOR(prv$m_netmbx,IOR(prv$m_cmkrnl,&
IOR(prv$m_detach,prv$m_bypass))))))))
print *, prvmsk

iret = sys$setprv ( %val(1), prvmsk, , )
call exit(iret)
end

http://www.mpp.mpg.de/~huber
Hein van den Heuvel
Honored Contributor

Re: FORTRAN Compile Link Error

>> The correct usage for integer oring is IOR(int1,int2).

Thanks for the reminder.
The (Alpha) compiler likes that.

>> does not need to have prvmsk defined as a 64 bit quantity, which has to be converted back into a 32bit quantity in the sys$... call.

The prvmsk is actually a 64 bit structure.

Hein
Joseph Huber_1
Honored Contributor

Re: FORTRAN Compile Link Error

>The prvmsk is actually a 64 bit structure.

Ah sorry, I overlooked that!

And the way $PRVDEF defines the PRV$M_* values
for bits above bit 31 ('00000000'X) will not work for .OR. or IOR(), at least in my 7.3-1 system, only the IBSET() method works correct:
e.g.
integer(kind=8) prvmsk
prvmsk=IOR(prv$m_security,prvmsk) does not change prvmsk.
The attached program prints the result.

Is this corrected in newer versions ?
http://www.mpp.mpg.de/~huber
Joseph Huber_1
Honored Contributor

Re: FORTRAN Compile Link Error

The result on my system OpenVMS V7.3-1
is

run test_priv
F0110021
70110021
F0110021
F0118021
40F0118021
40F0118021

i.e. the 40xxxxxxxx for SECURITY is not set with .OR.prv$M_security or IOR(prv$M_security,prvmsk), only with IBSET.
http://www.mpp.mpg.de/~huber
Joseph Huber_1
Honored Contributor

Re: FORTRAN Compile Link Error

And it is even (half:-) documented in the 7.3 system services manual:

Each bit has a symbolic name. The $PRVDEF macro defines these names. You form the bit vector by specifying the symbolic name of each desired privilege in a logical OR operation. The following table provides the symbolic name and description of each privilege:

And the table then lists the high order bits as PRV$V_mumble.
But of course one can not OR those.

So MJ26, take care in Your program not to use those privileges or switch from OR to IBSET !
http://www.mpp.mpg.de/~huber