Article 140434 of comp.os.vms:
Path: nntpd.lkg.dec.com!lead.zk3.dec.com!zk2nws.zko.dec.com!quark.enet.dec.com!lionel
From: lionel@quark.enet.dec.com (Steve Lionel)
Newsgroups: comp.os.vms
Subject: Re: VAX/VMS Compiler Query
Date: 16 Feb 1996 16:32:54 GMT
Organization: Digital Equipment Corporation, Nashua NH
Lines: 56
Distribution: world
Message-ID: <4g2bjm$3pd@zk2nws.zko.dec.com>
References: <960216044459_76702.1567_CHN71-1@CompuServe.COM>
Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
NNTP-Posting-Host: quark.zko.dec.com
X-Newsreader: mxrn 6.18-32


|>	hedleyj@wc6.wl.aecl.ca (Look, Natasha, is moose and squirrel!) writes:
|>>
|>>I recently ran into a problem using a proprietary matrix solver system. 
|>>Several modules had routines in which there were declaratives of the 
|>>form: 
|>>    
|>>         INTEGER  VAL(N) 
|>>    
|>>where N was an argument passed to the routine.  Simple enough.  The 
|>>modules were compiled with _default_ switches (i.e., no bounds checking). 
|>>In some cases N was passed as 0 and a run-time error occurred.  Bounds 
|>>checking was enforced, but this did not highlight the problem. 
|>>    
|>>Discussion with the vendor indicated that this situation does not occur 
|>>on some (if not all) Unix platforms.  For example, the package was 
|>>developed on a Sparc system, and the above does not cause the package 
|>>to stop. 
|>>    
|>>Question: does anyone know of a VMS Fortran switch to allow the routine 
|>>to continue after an "adjustable array dimension error" (this was the 
|>>message seen). 

If you have a condition handler enabled in the application (not in the
routine, but in the main program or some routine up the call tree from the
routine in question), it can intercept the FOR$_ADJARRDIM error and
return SS$_CONTINUE.  Here's an example:

	INTEGER*4 HANDLER (SIGARGS, MECHARGS)
	INTEGER*4 SIGARGS(0:*),MECHARGS(0:*)
	INCLUDE '($FORDEF)'
	INCLUDE '($SSDEF)'

	HANDLER = SS$_RESIGNAL
	IF (SIGARGS(1) .EQ. FOR$_ADJARRDIM) HANDLER=SS$_CONTINUE
	RETURN
	END

Now in your main program, put this:

	EXTERNAL HANDLER
	...
	CALL LIB$ESTABLISH(HANDLER)

The FORTRAN 77 language does not allow a zero-size array.  Fortran 90 does,
and I note that the Alpha compiler (77 or 90) will not generate this error for a
dimension of 0.
-- 

Steve Lionel                      Mail: lionel@quark.enet.dec.com
Fortran Development               WWW:  http://www.digital.com/info/slionel.html
Digital Equipment Corporation     CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698             "Free advice is worth every cent"

For information on Digital Fortran 90, see http://www.digital.com/info/hpc/f90/


