From nobody Sat Dec 11 13:45:02 2021 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 618CD18D56A7 for ; Sat, 11 Dec 2021 13:45:09 +0000 (UTC) (envelope-from feenberg@nber.org) Received: from mail2.nber.org (mail2.nber.org [198.71.6.79]) by mx1.freebsd.org (Postfix) with ESMTP id 4JB8Cn1kQlz3N2L for ; Sat, 11 Dec 2021 13:45:09 +0000 (UTC) (envelope-from feenberg@nber.org) Received: from mail2.nber.org (mail2.nber.org [198.71.6.79]) by mail2.nber.org (8.16.1/8.15.2) with ESMTPS id 1BBDj2AG093732 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 11 Dec 2021 08:45:02 -0500 (EST) (envelope-from feenberg@nber.org) Date: Sat, 11 Dec 2021 08:45:02 -0500 (EST) From: Daniel Feenberg To: Doug Hardie cc: freebsd-questions@freebsd.org Subject: Re: Fortran exceptions In-Reply-To: <2A944692-2C5A-4AF0-9E26-34C2142C5E3E@lafn.org> Message-ID: References: <2A944692-2C5A-4AF0-9E26-34C2142C5E3E@lafn.org> List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2044016298-2126462686-1639230302=:72931" X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Status: not scanned, disabled by settings X-KLMS-AntiSpam-Interceptor-Info: not scanned X-KLMS-AntiPhishing: Clean, 1970/01/01 00:00:00 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2021/12/11 09:28:00 #12827301 X-KLMS-AntiVirus-Status: Clean, skipped X-Rspamd-Queue-Id: 4JB8Cn1kQlz3N2L X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2044016298-2126462686-1639230302=:72931 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Fri, 10 Dec 2021, Doug Hardie wrote: > I have a fairly large fortran program that I am trying to run on flang. > It almost works, but I am sure there are a few typos in it. I had to > enter it by hand from a large listing. When it encounters a STOP, it > displays several ieee exception messages. Unfortunately there is no way > to identify where those occurred. How can I get the runtime to stop > when an exception occurs. This is on FreeBSD 13.0 release with whatever > flang is in the ports. I have found valgrind helpful with gfortran - I don't know if it works with flang. https://valgrind.org/docs/manual/manual-core.html#manual-core.whatdoes Flang can apparently generate code suitable for the gdb debugger, which can be useful. https://www.sourceware.org/gdb/ https://undo.io/resources/debugging-fortran-code-gdb/ https://www.scivision.dev/fortran-debugging-gdb/ Finally, if you can use gfortran, there are many options to improve runtime checking. You might be interested in --fpe-trap. https://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html As far as I can tell, flang has no equivalents, but I haven't used flang. It wouldn't install for me from ports or pkg's. Both complained my version of Freebsd (12.1) was unsuitable. Back in the 1970s there used to be the Watfor-77 compiler for the IBM 360, and later for Windows, which would check for uninitalized variables, subscripts out of range, type mismatches in subroutine calls, etc and provide a clear error message with no need to interpret hex constants. But compiler writers don't like to provide what they consider to be crutches for people less competent than themselves, so runtime error checking is usually neglected, sometimes vigorously. The IBM Fortran G compiler I first used in 1972 ran in 16K and provided a better error traceback than any currently available compiler I am familiar with except one: https://www.silverfrost.com/ Silverfrost does detect and report most runtime errors, but it is Windows only. Worth the money for many users, if you can stand working in Windows. The debugged program can go back to FreeBSD. This question might better go in a fortran-specific mailing list: https://groups.google.com/g/comp.lang.fortran https://fortran-lang.discourse.group/ Daniel Feenberg NBER --2044016298-2126462686-1639230302=:72931--