Compiling WRF/CHEM with KPP

Posts related to the installation of WRF Chemistry

Compiling WRF/CHEM with KPP

Postby ddonohoue » Wed Jun 22, 2011 8:52 am

I am new to WRF and WRF/CHEM but I have been trying to compile WRF with CHEM and KPP.
While I can compile WRF/CHEM without KPP when I try to compile with KPP I get the following errors.
My system uses pgi and gcc

First...
compile kpp
make[1]: Entering directory `/gpfs/env/mqq10ycu/WRF/V3.2.1/WRFV3/chem/KPP/kpp/kpp-2.1/src'
/gpfs/grace/bison-2.5/bin/yacc -d scan.y
gcc -O -c y.tab.c
flex scan.l
gcc -O -c lex.yy.c
scan.l:80: error: ‘INC_STATE’ undeclared here (not in a function)
scan.l:81: error: ‘MOD_STATE’ undeclared here (not in a function)
scan.l:82: error: ‘INT_STATE’ undeclared here (not in a function)
scan.l:83: error: ‘PRM_STATE’ undeclared here (not in a function)
scan.l:93: error: ‘ATM_STATE’ undeclared here (not in a function)

...

Second...
get_wrf_radicals.c:22: warning: incompatible implicit declaration of built-in function ‘strcpy’
gcc -I../../../../inc -c -g get_wrf_jvals.c
get_wrf_jvals.c: In function ‘get_wrf_jvals’:
get_wrf_jvals.c:19: warning: incompatible implicit declaration of built-in function ‘strcpy’

...

I saw that other links suggested that I need to make sure that the working directory was in the path so I added it using the following bash commmand {export PATH=".:$PATH"}

Any ideas?

Cheers,
Deanna
ddonohoue
 
Posts: 1
Joined: Fri Jun 17, 2011 4:02 am

Re: Compiling WRF/CHEM with KPP

Postby jlefevre » Sun Jun 26, 2011 6:55 am

Hi,

I'm not a KPP expert and just begining with WRFCHEM + kpp mechanism but I was facing with the same trouble like you. After playing with scan.l, i made some minor fix inside scan.l , and now, i can build kpp with yacc and gcc (My platform : Linux Fedora core 12 x86_64 (gcc version 4.1.2, Red Hat 4.1.2-33)

Please find my patch below :
Could you test ? If this patch fix your trouble too, we should to submit that to Chem developpers.
Enjoy !
J Lefevre

diff scan_old.l scan_new.l
79a80,115
>
> KEYWORD *keywords;
>
> #define RETURN( x ) \
> if(1) { \
> if ( yyerrflag == 0) { \
> strcpy( crtToken, nextToken ); \
> crtTokType = nextTokType; \
> crtLine = crt_line_no; \
> strcpy( crtFile, crt_filename ); \
> } \
> strcpy( nextToken, yytext); \
> nextTokType = x; \
> return (x); \
> }
> %}
>
> BT [ \t]
> SPACE [ \t]
> CR [\n]
> TAG [a-zA-Z_0-9]+
> STRING [^ \t\n{}#;]+
>
> LIT [a-zA-Z_]
> CIF [0-9]
>
> IDSPC {LIT}[a-zA-Z_0-9]*
>
> NR {CIF}*
> NRS [+-]?{CIF}+
> REAL {NRS}?"."?{NR}
> UREAL {NR}?"."?{NR}
> FLOAT {REAL}([eE]{NRS})?
> UFLOAT {UREAL}([eE]{NRS})?
> %%
>
133,155d168
< #define RETURN( x ) \
< if(1) { \
< if ( yyerrflag == 0) { \
< strcpy( crtToken, nextToken ); \
< crtTokType = nextTokType; \
< crtLine = crt_line_no; \
< strcpy( crtFile, crt_filename ); \
< } \
< strcpy( nextToken, yytext); \
< nextTokType = x; \
< return (x); \
< }
< %}
<
<
< BT [ \t]
< SPACE [ \t]
< CR [\n]
< TAG [a-zA-Z_0-9]+
< STRING [^ \t\n{}#;]+
<
< LIT [a-zA-Z_]
< CIF [0-9]
157,166d169
< IDSPC {LIT}[a-zA-Z_0-9]*
<
< NR {CIF}*
< NRS [+-]?{CIF}+
< REAL {NRS}?"."?{NR}
< UREAL {NR}?"."?{NR}
< FLOAT {REAL}([eE]{NRS})?
< UFLOAT {UREAL}([eE]{NRS})?
<
< %%
347c350
< yy_buffers[ yy_buf_level ] = yy_current_buffer;
---
> yy_buffers[ yy_buf_level ] = YY_CURRENT_BUFFER;
371c374
< oldb = yy_current_buffer;
---
> oldb = YY_CURRENT_BUFFER;
jlefevre
 
Posts: 6
Joined: Wed Mar 25, 2009 1:05 am

Re: Compiling WRF/CHEM with KPP

Postby jlefevre » Sun Jun 26, 2011 7:09 am

Oups,
Kpp is built with my fix but now there are some segmentation fault when using kpp !

/home/jlefevre/WRFV33_ifort/chem/KPP/kpp/kpp-2.1/bin/kpp gocartracm.kpp
make: *** [gocartracm_Integrator.f90] Segmentation fault

Likely my fix are the cause. May be a C expert may help to isolate the trouble...
Ok, tell you if I make some progress after sleeping.
Jerome
jlefevre
 
Posts: 6
Joined: Wed Mar 25, 2009 1:05 am

Re: Compiling WRF/CHEM with KPP

Postby jlefevre » Sun Jun 26, 2011 7:53 pm

Working Solution !
----------------------
The trouble is related with our flex version.
First, I found some redundant information with my prior fix in http://ruc.noaa.gov/wrf/WG11/KPP_yacc_flex_problems.pdf
but at the kpp chemical mechanism building time, kpp failed with Segmentation Fault.

FLEX Related error :
------------------------
The best wy is to download and install flex from source, using one used by the ncarg team :
Please, forget my last fix and start with your original files within src, do a make clean inside

Install flex like the common way :
cd /home/obama
mkdir New_flex; cd New_flex; wget http://www.ncl.ucar.edu/Download/files/flex.tar.gz
tar -xvzf flex.tar.gz ; vi readme ; configure --prefix=/home/obama/New_flex;make; make install

Then edit your Makefile.defs within chem/KPP/kpp/kpp-2.1/, with :
FLEX=/home/jlefevre/flex/bin/flex
FLEX_LIB_DIR=/home/jlefevre/flex/lib

Go to chem/KPP/kpp/kpp-2.1/src
make clean
make
That should to be right. There are some warning, you can add some include like :
scan.l :
line 45 #include <string.h>
gen.c :
line 37 :
#include <string.h>
#include <math.h>
...


write_decomp.exe Error :
---------------------------
In the chemical mechanism built with kpp, there are some error reated with write_decomp.exe not found.
The solution is at the end of : http://ruc.noaa.gov/wrf/WG11/KPP_yacc_flex_problems.pdf
You need to edit chem/KPP/util/write_decomp/Makefile like this :
Find the line
integr_edit.exe $(MECH)
and replace it with
./integr_edit.exe $(MECH)

Enjoy
Jerome
jlefevre
 
Posts: 6
Joined: Wed Mar 25, 2009 1:05 am

Re: Compiling WRF/CHEM with KPP

Postby sdk » Mon Oct 17, 2011 1:19 am

I have similar problem and the solution was to use version 2.5.3 of flex.
sdk
 
Posts: 14
Joined: Sun Mar 14, 2010 1:18 am

Re: Compiling WRF/CHEM with KPP

Postby liwanyuan » Fri Mar 07, 2014 12:21 am

Dear jlefevre:
I have followed your instructions to compile wrf/chem (3.5.1) with KPP but failed. The log file mainly told the following error message:
**********************************************************************************************************
This is KPP-2.1.
KPP is parsing the equation file.make: *** [nmhc9_Integrator.f90] Aborted (core dumped)
grep: ../../../module_kpp_nmhc9_Integr.F: No such file or directory
Makefile:50: warning: overriding commands for target `.F.o'
../../../../configure.wrf:324: warning: ignoring old commands for target `.F.o'
Makefile:58: warning: overriding commands for target `.c.o'
../../../../configure.wrf:351: warning: ignoring old commands for target `.c.o'
rm -f decomp_uses.inc
echo USE nmhc9_Parameters > decomp_uses.inc
echo USE nmhc9_JacobianSP >> decomp_uses.inc
ln -sf ../../../module_kpp_nmhc9_Precision.F
ln -sf ../../../module_kpp_nmhc9_Parameters.F
ln -sf ../../../module_kpp_nmhc9_JacobianSP.F
ln -sf ../../../module_kpp_nmhc9_Integr.F
make -i -r comp
make[1]: Entering directory `/home/lwy/wrf3.5.1/WRFV3/chem/KPP/util/write_decomp'
Makefile:50: warning: overriding commands for target `.F.o'
../../../../configure.wrf:324: warning: ignoring old commands for target `.F.o'
Makefile:58: warning: overriding commands for target `.c.o'
../../../../configure.wrf:351: warning: ignoring old commands for target `.c.o'
make[1]: *** No rule to make target `module_kpp_nmhc9_Precision.F', needed by `module_kpp_nmhc9_Precision.o'. Stop.
make[1]: Leaving directory `/home/lwy/wrf3.5.1/WRFV3/chem/KPP/util/write_decomp'
make: *** [all] Error 2
****************************************************************************************************************
Do you have some idea on this error? Thank you for your time in advance.
Best regard.
liwanyuan
 
Posts: 3
Joined: Thu Feb 20, 2014 4:33 am

Re: Compiling WRF/CHEM with KPP

Postby humaid » Sun May 04, 2014 11:16 am

Dear liwanyuan
I was able to replicate your error with WRF/CHEM (3.5.1) when I changed the files
scan.l and gen.c

Just start with fresh files and do as jlefevre explained without that step... that is do only :

FLEX Related error :
------------------------
The best wy is to download and install flex from source, using one used by the ncarg team :
Please, forget my last fix and start with your original files within src, do a make clean inside

Install flex like the common way :
cd /home/obama
mkdir New_flex; cd New_flex; wget http://www.ncl.ucar.edu/Download/files/flex.tar.gz
tar -xvzf flex.tar.gz ; vi readme ; configure --prefix=/home/obama/New_flex;make; make install

Then edit your Makefile.defs within chem/KPP/kpp/kpp-2.1/, with :
FLEX=/home/jlefevre/flex/bin/flex
FLEX_LIB_DIR=/home/jlefevre/flex/lib




AND

write_decomp.exe Error :
---------------------------
In the chemical mechanism built with kpp, there are some error reated with write_decomp.exe not found.
The solution is at the end of : http://ruc.noaa.gov/wrf/WG11/KPP_yacc_flex_problems.pdf
You need to edit chem/KPP/util/write_decomp/Makefile like this :
Find the line
integr_edit.exe $(MECH)
and replace it with
./integr_edit.exe $(MECH)
humaid
 
Posts: 7
Joined: Thu May 01, 2014 10:45 am

Re: Compiling WRF/CHEM with KPP

Postby liwanyuan » Wed Jul 02, 2014 6:42 am

Dear humaid:
Thank you very much for your reply, which works so well successfully!
Best regard!
Li Wanyuan
liwanyuan
 
Posts: 3
Joined: Thu Feb 20, 2014 4:33 am

Re: Compiling WRF/CHEM with KPP

Postby eus » Thu Feb 23, 2017 3:55 am

Could someone help me solve the same problem wrf-chem with KPP. I can't find the links mentioned above.
The compilation when setting KPP to 0 works fine.
Any urgent solution is welcome.
eus
eus
 
Posts: 21
Joined: Thu Jul 31, 2008 8:58 am

Re: Compiling WRF/CHEM with KPP

Postby dyah » Mon May 29, 2017 7:59 am

eus wrote:Could someone help me solve the same problem wrf-chem with KPP. I can't find the links mentioned above.
The compilation when setting KPP to 0 works fine.
Any urgent solution is welcome.
eus


you can download it on:
https://ruc.noaa.gov/wrf/wrf-chem/KPP_y ... oblems.pdf
dyah
 
Posts: 2
Joined: Thu May 25, 2017 1:10 am


Return to Installation

Who is online

Users browsing this forum: No registered users and 2 guests