KineticPreProcessor / KPP

The KPP kinetic preprocessor is a software tool that assists the computer simulation of chemical kinetic systems
GNU General Public License v3.0
22 stars 11 forks source link

Segmentation fault in generating the stoichiom file #64

Closed cshsgy closed 1 year ago

cshsgy commented 1 year ago

Hi, I was trying out the examples of KPP. However, an error comes up when I came to the compiling stage:


kpp small_f90.kpp 

This is KPP-3.0.0-rc.3.

KPP is parsing the equation file.
KPP is computing Jacobian sparsity structure.
KPP is starting the code generation.
KPP is initializing the code generation.
KPP is generating the monitor data:
    - small_f90_Monitor
KPP is generating the utility data:
    - small_f90_Util
KPP is generating the global declarations:
    - small_f90_Main
KPP is generating the ODE function:
    - small_f90_Function
KPP is generating the ODE Jacobian:
    - small_f90_Jacobian
    - small_f90_JacobianSP
KPP is generating the linear algebra routines:
    - small_f90_LinearAlgebra
KPP is generating the Hessian:
    - small_f90_Hessian
    - small_f90_HessianSP
KPP is generating the utility functions:
    - small_f90_Util
KPP is generating the rate laws:
    - small_f90_Rates
KPP is generating the parameters:
    - small_f90_Parameters
KPP is generating the global data:
    - small_f90_Global
KPP is generating the stoichiometric description files:
    - small_f90_Stoichiom
Segmentation fault (core dumped)

I used the files in the example folder, and they all fail at the same place. Is there a way to trace where the problem happens or does anyone have any ideas on how I can fix this?

yantosca commented 1 year ago

Thanks for writing @cshsgy. Are you building KPP on a Mac? I've noticed this issue on MacOS as well. I think it may have to do with the much lower amount of stack memory on MacOS than on Linux-based systems. You can try setting

export OMP_STACKSIZE=500m

which should set the stack memory to the maximum value on the system, and then rebuild again.

Also, if you don't need the stoichometric numbers, you can also disable that option with

#STOICHIOM off

Also tagging @RolfSander @jimmielin

yantosca commented 1 year ago

Re: stack memory on MacOSX, we have this documentation: https://kpp.readthedocs.io/en/stable/getting_started/01_installation.html#request-maximum-stack-memory

Cobaltito27 commented 1 year ago

Hi. I am using the latest KPP on a Windows Linux Subsystem (Ubuntu) and I also encountered the exact problem as well. I managed to set the stack limit to unlimit and recompiled the source code of KPP. But the problem persists.

When I check the small_strato.log file and generated .f90 files, it seems that they are interrupted. For example, below are line 71 to the rear of the file small_strato.log:

### Subroutines ---------------------------------------

SUBROUTINE Fun ( V, F, RCT, Vdot, Aout )
SUBROUTINE Fun_SPLIT ( V, F, RCT, Vdot, P_VAR, D_VAR, Aout )
SUBROUTINE CalcStoichNum ( StoichNum )
SUBROUTINE Jac_SP ( V, F, RCT, JVS )
SUBROU
cshsgy commented 1 year ago

Thanks for writing @cshsgy. Are you building KPP on a Mac? I've noticed this issue on MacOS as well. I think it may have to do with the much lower amount of stack memory on MacOS than on Linux-based systems. You can try setting

export OMP_STACKSIZE=500m

which should set the stack memory to the maximum value on the system, and then rebuild again.

Also, if you don't need the stoichometric numbers, you can also disable that option with

#STOICHIOM off

Also tagging @RolfSander @jimmielin

Hi @yantosca thanks for your reply! Yes I am using KPP in a UNIX-based system, but a x86-64 Ubuntu system. I tried your suggestion of changing the OMP stack size but also tried to set the ulimit, neither of them work and the error persists. What is strange to me is that, the log file shows nothing (an empty file created), which makes it quite hard to trace down the error. Thanks again for your kind help :D

prithvi09 commented 1 year ago

hello @cshsgy ! i was wondering if you solved the problem already ! I am facing the similar issue on my PC. I tried much to solve this but i failed to do so. can you help me ?

obin1 commented 1 year ago

@prithvi09, there's a 2 line change in this pull request: https://github.com/KineticPreProcessor/KPP/pull/67, which fixes the stack overflow and allows the STOICMAT option to run for me. I'm not sure if this has been validated or will get pulled into KPP at some point, but it has worked for my purposes

cshsgy commented 1 year ago

hello @cshsgy ! i was wondering if you solved the problem already ! I am facing the similar issue on my PC. I tried much to solve this but i failed to do so. can you help me ?

Hi! For me eventually ulimit -s unlimited solved the problem. I have to say the tutorial was poorly organized and we have to go to the very bottom of the page to find out the solution to this problem.

yantosca commented 1 year ago

This should be now solved by PR #67, which has been merged into KPP 3.0.1.