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

compilation error in older versions of KPP #72

Closed xin-chen-github closed 1 year ago

xin-chen-github commented 1 year ago

This question follows up on the previous question posted in geoschem repository https://github.com/geoschem/geos-chem/issues/1531 and is similar to #62 posted in the KPP repository here.

For research needs, we now need to modify chemical mechanism in GCv13.4.1 which requires KPPv2.3.3. When compiling KPPv2.3.3 (or a few other adjacent versions), I met the error message exactly the same as the picture attached in #62. The recommendation there was to switch to newer KPP versions, but I have mentioned in geoschem issue #1531 that newer versions of KPP require additional modifications to be consistent with GCv13.4.1 and eventually cause GCv13.4.1 segmentation fault, although KPP itself can be compiled successfully.

Any other thoughts on how to resolve the compilation error in #62 when compiling KPPv2.3.3. Does it require specific versions of related software packages such as gcc, flex, etc.?

Thanks, Xin

yantosca commented 1 year ago

Thanks for writing @xin-chen-github. That error means that KPP cannot find the flex library, which is one of its dependencies. In this version of KPP, this is set in the kpp-code/Makefile.defs file here:

https://github.com/geoschem/KPP/blob/f418e9dd60c872fb8d51dc0522cbef0f01b49e68/kpp-code/Makefile.defs#L53-L61

Note that this code snippet uses the ${FLEX_HOME} environment variable. You can set this to the path to your libfl.a or libfl.so file (i.e. the flex library file). In many cases this will be in the /usr/lib or /usr/local/lib path. If your system uses a software module package, ask your IT staff where this is. Then once you know, add this line to your .bashrc file:

export FLEX_HOME=/path/to/flex/library
yantosca commented 1 year ago

Oops and then you have to type . ~/.bashrc at the command line to accept the changes.

xin-chen-github commented 1 year ago

Thanks @yantosca for the thoughts. I'm pretty sure that I modified the flex library path in Makefile.def:

ifndef FLEX_HOME
 FLEX_LIB_DIR=~/flex/lib
else
 FLEX_LIB_DIR=$FLEX_HOME/lib
endif

And actually I have these defined in my .bashrc too, to confirm:

[xinch@svante-login ~]$ which flex
~/flex/bin/flex
[xinch@svante-login ~]$ echo $FLEX_HOME
/home/xinch/flex
[xinch@svante-login ~]$ echo $FLEX_LIB_DIR
/home/xinch/flex/lib

In my .bashrc, I have:

# flex for KPP
FLEX_HOME=~/flex
#export FLEX_HOME
export PATH=$PATH:$FLEX_HOME/bin
# bison for KPP
BISON_HOME=~/bison
#export BISON_HOME
export PATH=$PATH:$BISON_HOME/bin
# KPP
FLEX_LIB_DIR=$FLEX_HOME/lib
export FLEX_LIB_DIR
export PATH=$PATH:$FLEX_LIB_DIR
KPP_HOME=~/tmpfolder/KPP/kpp-code
export KPP_HOME
export PATH=$PATH:$KPP_HOME/bin

Any further thoughts on what's going on?

Thanks, Xin

yantosca commented 1 year ago

Thanks for the info @xin-chen-github. Try adding FLEX_LIB_DIR to the LD_LIBRARY_PATH variable in your .bashrc:

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${FLEX_LIB_DIR}:"
xin-chen-github commented 1 year ago

The "can't find library" error disappeared already, although I don't really know from which step of the debugging it disappeared... distracted by many lines of the warning messages above it #62.

Is it fine to proceed with those warning messages?

Thanks, Xin

yantosca commented 1 year ago

@xin-chen-github: Yes, those warning messages are OK. We got rid of them in KPP 2.5.0 and later. They are basically complaining about C-language syntax (unused variables, missing function prototypes, etc). Warnings are harmless but Errors are fatal.

xin-chen-github commented 1 year ago

Thank you @yantosca, works fine now, I'll close this issue.