Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Appendix D Using the ON statement

Allowing core dumps with the ON statement

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

By default, if a program includes the ON statement or has been compiled with the +fp_exception option, a procedure traceback is produced for any error that causes the program to abort. (This option is described in Chapter 13.) You can use the traceback information when debugging. For example, the following traceback,

( 0)  0x0000203c   subr + 0x98  [./a.out]
( 1)  0x00001f4c   main + 0x74  [./a.out]

identifies the absolute address of the faulting instruction (0x0000203c), the name of the procedure (subr) that contains the instruction and the instruction's offset (0x98) within the procedure, and the name of the executable.

But you may wish to allow a core dump for one or more signals for a program that includes the ON statement. To do so, you must revise the program to restore the default behavior for each signal. For example, you may wish to handle floating-point conditions with the ON statement, but still allow a core dump to be generated for other signals (for example, a bus error).

The following program uses the libU77 signal routine to reset the default behavior for a bus error signal. The program uses the ON statement to handle floating-point conditions, but allows a core dump when a bus error occurs:

PROGRAM main
ON REAL OVERFLOW IGNORE
CALL subr
END
 
PROCEDURE subr
DOUBLE PRECISION d
POINTER (ip, d) !Cray-style pointer
REAL :: x, y
 
INTEGER sigbus, sigdfl
PARAMETER(sigbus=10)
PARAMETER(sigdfl=0)
 
INTEGER sigrtn, SIGNAL
 
! Set the action for bus error to be the default
!   (DUMP CORE).  This overrides the action of
!   generating a procedure traceback that is
!   established by using the ON statement.
 
sigrtn = SIGNAL(sigbus, 0, sigdfl)
 
! The next statements cause a real overflow
x = 1.0E38
x = y * 10.0
 
! Bus error is caused by the next statements
ip = MALLOC(40)
ip = ip + 4      ! ip is now 4-byte aligned
d = 99.0         ! bus error
END

Use the following command line to compile this program:

f90 +U77 main.f90
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.