Fortran LIB$WAIT fails with invalid arguments

OpenVMS x86 native compilers, cross compilers news and questions.
Post Reply

Topic author
alexwong
Contributor
Posts: 21
Joined: Tue Apr 23, 2024 6:28 am
Reputation: 0
Status: Offline

Fortran LIB$WAIT fails with invalid arguments

Post by alexwong » Sat May 04, 2024 11:38 pm

My Fortran LIB$WAIT test program always fail with %LIB-F-INVARG, invalid argument(s) regardless of what /FLOAT compile switch I use or the float type argument to the routine. I wrote a similar C test program and that works BUT the float type argument must be specified otherwise it too fails with %SYSTEM-F-FLTINV, floating invalid operation. I believe the default float type is IEEE_S in Fortran or C but for some reason, it's not working properly with LIB$WAIT. Maybe the problem is specific to x86 but I don't have a real box to confirm.

Virtualbox Version 7.0.14 r161095 (Qt5.15.2)
Windows 11
x86 OpenVMS 9.2-2 VMDK
Attachments
TESTWAIT_FOR.TXT
(536 Bytes) Downloaded 12 times
TESTWAIT.C
(589 Bytes) Downloaded 11 times


anachronda
Visitor
Posts: 2
Joined: Sat May 04, 2024 11:48 pm
Reputation: 0
Status: Offline

Re: Fortran LIB$WAIT fails with invalid arguments

Post by anachronda » Sun May 05, 2024 12:02 am

you need an include '($libwaitdef)' in there somewhere.

Code: Select all

	program argh
	include '($libwaitdef)'
	real wait
	integer r0

	wait=3.4
	print *,'start wait', wait, ' secs'
	r0 = lib$wait( wait, lib$k_nowake, lib$k_ieee_s )
	call lib$signal( %val( r0 ) )
	print *,'end wait r0=',r0
	end
Added in 3 minutes 57 seconds:
i should have mentioned that this would have been more clear had there been an implicit none. since there isn't, the compiler has helpfully created integers name lib$k_nowake and lib$k_ieee_s, which you haven't initialized.

Code: Select all

	program argh
	implicit none
	print *,lib$k_nowake
	print *,lib$k_ieee_s
	end
compilation yields:

Code: Select all

$ for argh

	print *,lib$k_nowake
................^
%F90-E-ERROR, This name does not have a type, and must have an explicit type.   
[LIB$K_NOWAKE]
at line number 3 in file DKA0:[RIVIE.BOOGER]ARGH.FOR;5

	print *,lib$k_ieee_s
................^
%F90-E-ERROR, This name does not have a type, and must have an explicit type.   
[LIB$K_IEEE_S]
at line number 4 in file DKA0:[RIVIE.BOOGER]ARGH.FOR;5
$


sms
Master
Posts: 376
Joined: Fri Aug 21, 2020 5:18 pm
Reputation: 0
Status: Offline

Re: Fortran LIB$WAIT fails with invalid arguments

Post by sms » Sun May 05, 2024 12:25 am

Code: Select all

> include '($libwaitdef)'

   Or:

its $ gdiff TESTWAIT.FOR TESTWAIT3.FOR
16c16
<         r0=lib$wait(wait,LIB$K_NOWAKE,LIB$K_IEEE_S)
---
>         r0=lib$wait( wait, 1, 4)


> [...] implicit none [...]

   One of the best things ever to happen to FORTRAN/Fortran.


Topic author
alexwong
Contributor
Posts: 21
Joined: Tue Apr 23, 2024 6:28 am
Reputation: 0
Status: Offline

Re: Fortran LIB$WAIT fails with invalid arguments

Post by alexwong » Sun May 05, 2024 12:45 am

Thanks that worked! Good pick up. I've been so used to modern compilers picking up these errors that I totally forgot about implicit none in Fortran. Funny to think 40 years ago, I worked with it every day.

User avatar

arne_v
Master
Posts: 376
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Fortran LIB$WAIT fails with invalid arguments

Post by arne_v » Sun May 05, 2024 7:50 am

There are a few LIB$ functions where I actually prefer the system services.

LIB$WAIT is one of them.

integer*8 t
...
call sys$schdwk(, , t, )
call sys$hiber()

seems more natural to me.

(t is a VMS delta time so negative number of 100ns units)
Arne
arne@vajhoej.dk
VMS user since 1986


Topic author
alexwong
Contributor
Posts: 21
Joined: Tue Apr 23, 2024 6:28 am
Reputation: 0
Status: Offline

Re: Fortran LIB$WAIT fails with invalid arguments

Post by alexwong » Sun May 05, 2024 7:58 pm

I like it Arne, I'm gonna use this instead. None of this float type nonsense.

Post Reply