Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler flags identifying floating divide by zero runtime error #55

Open
davidcraigpenner opened this issue Nov 6, 2021 · 2 comments

Comments

@davidcraigpenner
Copy link

davidcraigpenner commented Nov 6, 2021

The version number of the MASA library (versioning information can be obtained by running the masa_version binary located in the bin/ directory of a local MASA installation)
the hardware and operating system

-------------------------------------------------------------------------------
MASA Library: Version = 0.51.0 (5100)

Development Build

Build Date   = 2019-10-09 14:05
Build Host   = nia-login05.scinet.local
Build User   = dcp
Build Arch   = x86_64-pc-linux-gnu
Build Rev    = 7351ff92

C++ Config   = mpicxx -O0
F90 Config   = mpifc-O0

Optional Features:
   Python support enabled = no
-------------------------------------------------------------------------------

A description of the bug behavior
I am using MASA via the Fortran90 interface and compiling my source code with the following Intel Fortran compiler:

mpif90 for the Intel(R) MPI Library 2018 Update 3 for Linux*
Copyright(C) 2003-2018, Intel Corporation.  All rights reserved.
__INTEL_PRE_FFLAGS options:  -gcc-name=core-gcc -gxx-name=core-g++
ifort version 18.0.3

When I use the following flags (among others) to compile my source code, specifically

-check all,noarg_temp_created -init=snan -init=zero -init=arrays

I obtain the following runtime error when running my executable:

forrtl: error (73): floating divide by zero
Image              PC                Routine            Line        Source
jetstream_x86_64   000000000043E8CE  Unknown               Unknown  Unknown
libpthread-2.17.s  00002B34AD110630  Unknown               Unknown  Unknown
jetstream_x86_64   00000000004FEEA1  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB54832D  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB547F7B  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB546D84  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB482130  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB480A9A  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB48C254  _ZN4MASA9masa_ini     Unknown  Unknown
libfmasa-0.51.so   00002B34AB5147C0  masa_init             Unknown  Unknown
libfmasa-0.51.so   00002B34AB4804DB  masa_mp_masa_init     Unknown  Unknown
libdiablo.so       00002B34A05933CE  verify_mod_mp_gen       10911  Verify_Mod.f90

For reference, Line 10911 in my Fortran90 source code is a call to masa_init:

!-- initialize the problem
call masa_init('test',trim(adjustl(desired_mms_function)))

where desired_mms_function = 'euler_2d'. Note that when I compile without the aforementioned flags (i.e., without -check all,noarg_temp_created -init=snan -init=zero -init=arrays), MASA runs correctly. For reference, the functions of the flags of interest are as follows (more info here):

  • -init=arrays specifies that we initialize all unitialized arrays and variables by the following;
  • -init=nan initializes all unitialized REAL and COMPLEX variables/arrays to nans to get caught by the nantrapping
  • -init=zero initializes all unitialized REAL, COMPLEX, INTEGER, and LOGICAL variables/arrays to zero

My guess is that there are some unintialized variables in MASA, potentially in fans_sa.cpp (based on the above error message that I am getting), that are being caught by these flags, however I have been unable to identify specifically what part of the code is leading to the runtime error. Does anyone know how to address this issue?

@davidcraigpenner davidcraigpenner changed the title Compiler flags leading to floating divide by zero runtime error Compiler flags identifying floating divide by zero runtime error Nov 6, 2021
@roystgnr
Copy link
Member

Do you get any runtime errors from make check?

I tried running all our test applications with valgrind, but no reported errors there. (Which doesn't mean no uninitialized values, IIRC, because valgrind only catches those when they affect a branch condition)

I also tried a build with

../configure --enable-fortran-interfaces CXXFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0 -fno-unsafe-math-optimizations -Dgnu_compiler -Wno-literal-suffix' ac_test_CXXFLAGS=set CFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0 -fno-unsafe-math-optimizations -Dgnu_compiler -Wno-builtin-declaration-mismatch -Wno-implicit-function-declaration' ac_test_CFLAGS=set FCFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0'

but I don't see any uninitialized variable warnings from the compiler and I still pass make check.

@davidcraigpenner
Copy link
Author

I do not get any runtime errors with make check. Thanks for running those tests. I tried a build with the additional flags you mention, i.e.,

./configure --prefix=$PREFIX --enable-fortran-interfaces CXXFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0 -fno-unsafe-math-optimizations -Dgnu_compiler -Wno-literal-suffix' ac_test_CXXFLAGS=set CFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0 -fno-unsafe-math-optimizations -Dgnu_compiler -Wno-builtin-declaration-mismatch -Wno-implicit-function-declaration' ac_test_CFLAGS=set FCFLAGS='-Wuninitialized -Wmaybe-uninitialized -Werror -O0'

however when I look at the summary of the build, it seems like some of the specified flags are not being used:

----------------------------------- SUMMARY -----------------------------------

Package version................. : masa-0.51.0

C++ compiler.................... : mpicxx
C++ compiler flags.............. : -O0
C compiler...................... : mpicc
C compiler flags................ : -O0 -fp-model precise -Dintel_compiler
Install dir..................... : /home/z/zingg/dcp/jetstream/masa
Build user...................... : dcp
Build host...................... : nia-login05.scinet.local
Configure date.................. : 2021-11-11 09:24
Build architecture.............. : x86_64-pc-linux-gnu
Source control revision......... : 48d2494bf

Optional Features:
   Enable gcov code coverage.... : no
   MetaPhysicL.................. : no
   Enable absolute error tests.. : no
   Enable all warnings.......... : no
   Enable python interfaces..... : no
   Enable fortran interfaces.... : yes
Fortran compiler................ : mpifc
Fortran compiler flags.......... : -O0

-------------------------------------------------------------------------------

Perhaps some of the flags are skipped because I am using MPI compilers? Or am I interpreting the summary incorrectly?

Also, are there some flags I could build MASA with that would provide more detailed error information? For example, the current error message I get when I run my executable does not indicate any Line or Source information for MASA, however having this additional information would be helpful for identifying the problem:

forrtl: error (73): floating divide by zero
Image              PC                Routine            Line        Source
jetstream_x86_64   000000000043E8CE  Unknown               Unknown  Unknown
libpthread-2.17.s  00002B34AD110630  Unknown               Unknown  Unknown
jetstream_x86_64   00000000004FEEA1  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB54832D  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB547F7B  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB546D84  _ZN4MASA27fans_sa     Unknown  Unknown
libfmasa-0.51.so   00002B34AB482130  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB480A9A  Unknown               Unknown  Unknown
libfmasa-0.51.so   00002B34AB48C254  _ZN4MASA9masa_ini     Unknown  Unknown
libfmasa-0.51.so   00002B34AB5147C0  masa_init             Unknown  Unknown
libfmasa-0.51.so   00002B34AB4804DB  masa_mp_masa_init     Unknown  Unknown
libdiablo.so       00002B34A05933CE  verify_mod_mp_gen       10911  Verify_Mod.f90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants