svalinn / DAGMC

Direct Accelerated Geometry Monte Carlo Toolkit
https://svalinn.github.io/DAGMC
Other
96 stars 63 forks source link

Simple logger #876

Closed gonuke closed 1 year ago

gonuke commented 1 year ago

This is an attempt to streamline and add code re-use to @pshriwise's PR #872.

Per @pshriwise: This is a step toward improved console logging in some of our classes. As described in #856, DAGMC and other classes in MOAB always write some output, which can conflict with output in downstream applications and cause confusion.

A DagMC_Logger object is added to the DagMC class and the dagmcmetadata class. The DagMC_Logger has methods message, warning, and error. The first two write to std::cout and the third to std::cerr. Warnings and errors will always be written.

Also borrowed from @pshriwise: The message will either be written to screen or not depending on the verbosity level set on the class instance. I've specified two levels of verbosity for now, but I'm open to a more fine grain set of verbosity levels down the line.

ahnaf-tahmid-chowdhury commented 1 year ago

It appears that there is an error in building the pt_vol_test executable. The error message indicates that there is an undefined reference to moab::DagMC::DagMC(std::shared_ptr<moab::Interface>, double, double). This means that the linker ld is unable to find the definition of this function.

gonuke commented 1 year ago

This is working for our tests. Can you provide more build log info about your failure?

ahnaf-tahmid-chowdhury commented 1 year ago

Sure.

-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.34.1") 
-- Submodule update

-- CMAKE_BUILD_TYPE not specified, defaulting to Release
-- CMAKE_BUILD_TYPE: Release

-- MOAB_CMAKE_CONFIG: /opt/nuclear-boy/lib/cmake/MOAB/MOABConfig.cmake
-- Found HDF5: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libcurl.so;pthread;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;dl;/usr/lib/x86_64-linux-gnu/libm.so (found version "1.10.7")  
-- HDF5_INCLUDE_DIRS: /usr/include/hdf5/serial
-- HDF5_LIBRARIES_SHARED: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libcurl.so;pthread;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;dl;/usr/lib/x86_64-linux-gnu/libm.so
-- HDF5_LIBRARIES_STATIC: 
-- MOAB_INCLUDE_DIRS: /opt/nuclear-boy/include;/usr/include/eigen3
-- MOAB_LIBRARY_DIRS: /opt/nuclear-boy/lib
-- MOAB_LIBRARIES_SHARED: /opt/nuclear-boy/lib/libMOAB.so
-- MOAB_LIBRARIES_STATIC: 
-- Found MOAB
-- Could NOT find OpenMP_C (missing: OpenMP_pthread_LIBRARY) (found version "4.5")
-- Could NOT find OpenMP_CXX (missing: OpenMP_pthread_LIBRARY) (found version "4.5")
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 

-- Building shared executables
-- INSTALL_RPATH_DIRS: /opt/nuclear-boy/lib
-- CMAKE_C_FLAGS: 
-- CMAKE_CXX_FLAGS: 
-- CMAKE_Fortran_FLAGS: 
-- CMAKE_C_FLAGS_RELEASE: -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -O3 -DNDEBUG
-- CMAKE_Fortran_FLAGS_RELEASE: 
-- CMAKE_C_IMPLICIT_LINK_LIBRARIES: 
-- CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: stdc++
-- CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES: 
-- CMAKE_EXE_LINKER_FLAGS: 
-- Building gtest

-- Building library: dagmc
-- LINK LIBS: /opt/nuclear-boy/lib/libMOAB.so;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libcurl.so;pthread;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;dl;/usr/lib/x86_64-linux-gnu/libm.so
-- Building executable: pt_vol_test
-- Building executable: ray_fire_test
-- Building executable: test_geom
-- Building unit tests: dagmc_unit_tests
-- Building unit tests: dagmc_pointinvol_test
-- Building unit tests: dagmc_rayfire_test
-- Building unit tests: dagmc_simple_test
-- Building unit tests: dagmc_graveyard_test

-- Building library: uwuw
-- LINK LIBS: dagmc-shared;pyne_dagmc-shared
-- Building executable: uwuw_preproc
-- Building unit tests: uwuw_unit_tests
-- Building unit tests: uwuw_unit_tests_tally
-- Building unit tests: uwuw_unit_tests_preprocessor

-- PyNE AMALGAMATION SUCCESSFUL atomic_data.h generated is the same as existing file, skipping.
atomic_data.cpp generated is the same as existing file, skipping.
renamed 'pyne.cpp.new' -> 'pyne.cpp'
'/opt/nuclear-boy/dagmc-repo/src/pyne/pyne/share/source.F90' -> '/opt/nuclear-boy/dagmc-repo/src/pyne/../mcnp/mcnp5/pyne_source/source.F90'
'/opt/nuclear-boy/dagmc-repo/src/pyne/pyne/share/source_mcnp6.F90' -> '/opt/nuclear-boy/dagmc-repo/src/pyne/../mcnp/mcnp6/pyne_source/source.F90'

-- Building library: pyne_dagmc
-- LINK LIBS: /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so;/usr/lib/x86_64-linux-gnu/libcrypto.so;/usr/lib/x86_64-linux-gnu/libcurl.so;pthread;/usr/lib/x86_64-linux-gnu/libsz.so;/usr/lib/x86_64-linux-gnu/libz.so;dl;/usr/lib/x86_64-linux-gnu/libm.so;/opt/nuclear-boy/lib/libMOAB.so

-- Building library: dagtally
-- LINK LIBS: dagmc-shared
-- Building unit tests: test_KDEKernel
-- Building unit tests: test_KDEMeshTally
-- Building unit tests: test_KDENeighborhood
-- Building unit tests: test_PolynomialKernel
-- Building unit tests: test_Quadrature
-- Building unit tests: test_CellTally
-- Building unit tests: test_TallyEvent
-- Building unit tests: test_TallyData
-- Building unit tests: test_Tally
-- Building unit tests: test_TrackLengthMeshTally

-- Building executable: build_obb

-- Building library: makeWatertight
-- LINK LIBS: dagmc-shared
-- Building executable: make_watertight
-- Building executable: check_watertight
-- Building unit tests: make_watertight_cylinder_tests
-- Building unit tests: make_watertight_cone_tests
-- Building unit tests: make_watertight_no_curve_sphere_tests
-- Building unit tests: make_watertight_sphere_n_box_test

Found Geant4 version 11.1.1
-- Geant4_CMAKE_CONFIG: /opt/nuclear-boy/lib/cmake/Geant4/Geant4Config.cmake
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found Geant4: /opt/nuclear-boy/lib/cmake/Geant4/Geant4Config.cmake (found suitable version "11.1.1", minimum required is "10.4.2") 
-- Geant4 version: 11.1.1
-- Geant4 version required: 10.4.2
-- Geant4 version compatible: true
-- Geant4 version exact: 
-- Geant4_INCLUDE_DIRS: /opt/nuclear-boy/include/Geant4
-- Geant4_LIBRARIES_SHARED: Geant4::G4Tree;Geant4::G4FR;Geant4::G4GMocren;Geant4::G4visHepRep;Geant4::G4RayTracer;Geant4::G4VRML;Geant4::G4ToolsSG;Geant4::G4vis_management;Geant4::G4modeling;Geant4::G4interfaces;Geant4::G4persistency;Geant4::G4analysis;Geant4::G4error_propagation;Geant4::G4readout;Geant4::G4physicslists;Geant4::G4run;Geant4::G4event;Geant4::G4tracking;Geant4::G4parmodels;Geant4::G4processes;Geant4::G4digits_hits;Geant4::G4track;Geant4::G4particles;Geant4::G4geometry;Geant4::G4materials;Geant4::G4graphics_reps;Geant4::G4intercoms;Geant4::G4global;Geant4::G4tools;Geant4::G4clhep;Geant4::G4expat;Geant4::G4zlib;Geant4::G4ptl;Geant4::G4UIVisDefinitions
-- Geant4_LIBRARIES_STATIC: 
-- Geant4_DEFINITIONS: 
-- Geant4_CXX_FLAGS: -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -pthread -ftls-model=initial-exec -std=c++17
-- Geant4_CXX_FLAGS_RELEASE: -O3 -DNDEBUG -fno-trapping-math -ftree-vectorize -fno-math-errno
-- Geant4_EXE_LINKER_FLAGS: 
-- Found Geant4
-- Configuring DAGMC for Geant4 version >= 11.0
-- Building library: dagsolid
-- LINK LIBS: Geant4::G4Tree;Geant4::G4FR;Geant4::G4GMocren;Geant4::G4visHepRep;Geant4::G4RayTracer;Geant4::G4VRML;Geant4::G4ToolsSG;Geant4::G4vis_management;Geant4::G4modeling;Geant4::G4interfaces;Geant4::G4persistency;Geant4::G4analysis;Geant4::G4error_propagation;Geant4::G4readout;Geant4::G4physicslists;Geant4::G4run;Geant4::G4event;Geant4::G4tracking;Geant4::G4parmodels;Geant4::G4processes;Geant4::G4digits_hits;Geant4::G4track;Geant4::G4particles;Geant4::G4geometry;Geant4::G4materials;Geant4::G4graphics_reps;Geant4::G4intercoms;Geant4::G4global;Geant4::G4tools;Geant4::G4clhep;Geant4::G4expat;Geant4::G4zlib;Geant4::G4ptl;Geant4::G4UIVisDefinitions;dagmc-shared;pyne_dagmc-shared;uwuw-shared
-- Building executable: DagGeant4
-- Building unit tests: dagsolid_unit_tests

-- Building executable: overlap_check
-- Building unit tests: overlap_check_test

-- DAGMC cmake config file: /opt/nuclear-boy/lib/cmake/dagmc/DAGMCConfig.cmake
-- DAGMC cmake version file: /opt/nuclear-boy/lib/cmake/dagmc/DAGMCConfigVersion.cmake

-- Configuring done
-- Generating done
-- Build files have been written to: /opt/nuclear-boy/dagmc-repo/build
[  1%] Building CXX object src/gtest/CMakeFiles/gtest.dir/gtest-1.8.0/src/gtest-all.cc.o
[  2%] Linking CXX static library libgtest.a
[  2%] Built target gtest
[  3%] Building CXX object src/dagmc/CMakeFiles/dagmc-shared.dir/DagMC.cpp.o
[  4%] Building CXX object src/dagmc/CMakeFiles/dagmc-shared.dir/dagmcmetadata.cpp.o
[  4%] Linking CXX shared library libdagmc.so
[  4%] Built target dagmc-shared
[  4%] Building CXX object src/dagmc/tools/CMakeFiles/pt_vol_test.dir/pt_vol_test.cpp.o
[  5%] Linking CXX executable pt_vol_test
/usr/bin/ld: CMakeFiles/pt_vol_test.dir/pt_vol_test.cpp.o: in function `main':
pt_vol_test.cpp:(.text.startup+0x25e): undefined reference to `moab::DagMC::DagMC(std::shared_ptr<moab::Interface>, double, double)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/dagmc/tools/CMakeFiles/pt_vol_test.dir/build.make:105: src/dagmc/tools/pt_vol_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:541: src/dagmc/tools/CMakeFiles/pt_vol_test.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Consolidate compiler generated dependencies of target gtest
[  2%] Built target gtest
Consolidate compiler generated dependencies of target dagmc-shared
[  4%] Built target dagmc-shared
Consolidate compiler generated dependencies of target pt_vol_test
[  5%] Linking CXX executable pt_vol_test
/usr/bin/ld: CMakeFiles/pt_vol_test.dir/pt_vol_test.cpp.o: in function `main':
pt_vol_test.cpp:(.text.startup+0x25e): undefined reference to `moab::DagMC::DagMC(std::shared_ptr<moab::Interface>, double, double)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/dagmc/tools/CMakeFiles/pt_vol_test.dir/build.make:105: src/dagmc/tools/pt_vol_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:541: src/dagmc/tools/CMakeFiles/pt_vol_test.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I am assumeing DagMC.hpp is not properly included in the source file.

gonuke commented 1 year ago

Is it possible that you're finding an old header file in your system? The pt_vol_test calls a default constructor. If it's using the new header file, it should be looking for a different signature <shared_ptr>...., double, double, int than the one it's looking for... Not sure what other problem there may be?

pshriwise commented 1 year ago

Is it possible that you're finding an old header file in your system? The pt_vol_test calls a default constructor. If it's using the new header file, it should be looking for a different signature <shared_ptr>...., double, double, int than the one it's looking for... Not sure what other problem there may be?

I meant to make an issue for this. I believe DAGMC (even prior to this PR) will include the headers in the installed location if they exist (i.e. if DAGMC has been installed in that location previously).

ahnaf-tahmid-chowdhury commented 1 year ago

Is it possible that you're finding an old header file in your system? The pt_vol_test calls a default constructor. If it's using the new header file, it should be looking for a different signature <shared_ptr>...., double, double, int than the one it's looking for... Not sure what other problem there may be?

I meant to make an issue for this. I believe DAGMC (even prior to this PR) will include the headers in the installed location if they exist (i.e. if DAGMC has been installed in that location previously).

Yes. I've recently performed a clean install (delete previous versions of DAGMC) and haven't encountered any problems so far. However, the issue still needs to be resolved and I'm not sure how to go about fixing it. I need to do some research.