OPM / opm-common

Common components for OPM, in particular build system (cmake).
http://www.opm-project.org
GNU General Public License v3.0
33 stars 111 forks source link

EclipseState::handle_schedule_keyword segfaults in parallel. #2922

Closed blattms closed 2 years ago

blattms commented 2 years ago

The problem is that we call EclipseState::handle_schedule_keywords which calls the same function on the field_props (shared_ptrto FiedlPropsManager) member at EclipseState.cpp#L398 Unfortunately, in parallel this is a nullptr on all processes except the master process.

#0  0x00005555580deb25 in Opm::FieldProps::handle_schedule_keywords (this=0x0, keywords=std::vector of length 1, capacity 1 = {...})
    at opm-common/src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp:1276
#1  0x0000555557a6f35c in Opm::FieldPropsManager::apply_schedule_keywords (this=0x55555d669890, 
    keywords=std::vector of length 1, capacity 1 = {...})
    at opm-common/src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp:51
#2  0x0000555557a69c9e in Opm::EclipseState::apply_schedule_keywords (this=0x55555d666750, 
    keywords=std::vector of length 1, capacity 1 = {...})
    at opm-common/src/opm/input/eclipse/EclipseState/EclipseState.cpp:398
#3  0x0000555555732ecd in Opm::EclProblem<Opm::Properties::TTag::EclFlowProblem>::beginEpisode (this=0x55555f0277a0)
    at opm-simulators/ebos/eclproblem.hh:1021
#4  0x00005555557142e3 in Opm::BlackoilModelEbos<Opm::Properties::TTag::EclFlowProblem>::beginReportStep (this=0x55555ef8fb00)
    at opm-simulators/opm/simulators/flow/BlackoilModelEbos.hpp:1089
#5  0x00005555556f7914 in Opm::SimulatorFullyImplicitBlackoilEbos<Opm::Properties::TTag::EclFlowProblem>::runStep (
    this=0x55555ef704c0, timer=...)
    at opm-simulators/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp:238
#6  0x00005555556e2dd8 in Opm::SimulatorFullyImplicitBlackoilEbos<Opm::Properties::TTag::EclFlowProblem>::run (this=0x55555ef704c0, 
    timer=...) at opm-simulators/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp:153
#7  0x00005555556d1ecb in Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::runSimulatorRunCallback_ (this=0x55555c61e650)
    at opm-simulators/opm/simulators/flow/FlowMainEbos.hpp:554
#8  0x00005555556d1dc1 in Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::runSimulatorInitOrRun_ (this=0x55555c61e650, 
    initOrRunFunc=(int (Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::*)(Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem> * const)) 0x5555556d1e7a <Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::runSimulatorRunCallback_()>)
    at opm-simulators/opm/simulators/flow/FlowMainEbos.hpp:624
#9  0x00005555556c3e01 in Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::runSimulator (this=0x55555c61e650)
    at opm-simulators/opm/simulators/flow/FlowMainEbos.hpp:542
#10 0x00005555556c3bb1 in Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::execute_ (this=0x55555c61e650, 
    runOrInitFunc=(int (Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::*)(Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem> * const)) 0x5555556c3dd0 <Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::runSimulator()>, cleanup=true)
    at opm-simulators/opm/simulators/flow/FlowMainEbos.hpp:406
#11 0x00005555556b8914 in Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>::execute (this=0x55555c61e650)
    at opm-simulators/opm/simulators/flow/FlowMainEbos.hpp:317
#12 0x0000555555667a0d in Opm::flowEbosBlackoilMain (argc=2, argv=0x7fffffffd578, outputCout=false, outputFiles=true)
    at opm-simulators/flow/flow_ebos_blackoil.cpp:63
#13 0x00005555556420f3 in Opm::Main::runBlackOil (this=0x7fffffffd390)
    at opm-simulators/opm/simulators/flow/Main.hpp:711
#14 0x00005555556408ff in Opm::Main::dispatchDynamic_ (this=0x7fffffffd390)
    at opm-simulators/opm/simulators/flow/Main.hpp:327
#15 0x000055555564049d in Opm::Main::runDynamic (this=0x7fffffffd390)
    at opm-simulators/opm/simulators/flow/Main.hpp:227
#16 0x000055555562748d in main (argc=2, argv=0x7fffffffd578) at opm-simulators/flow/flow.cpp:29

When the simulator calls this function during the simulation (e,g, eclproblem.hh#L1021-L1022) It at least makes sure that the transmissibilty multipliers get broadcast. Changes to FieldProperties get lost, though.

The segmentation fault appears for e.g. for keyword MULTFTL (reproducible with mpirun -np 2 flow model2/3_A_MPI_MULTFLT_SCHED_MODEL2).

blattms commented 2 years ago

I am preparing a fix that will check whether field_props in a nullptr and in that case does not change the field_props. That might fix the segfault for MULTFLT but not anything else.