Update version info for release v4.6.1 (#2122)
[WRF.git] / chem / KPP / compile_wkc
blob1d0cdc190c442b149ac7d5bdabe1a972cd88a4e4
1 #!/bin/csh -f
4 echo "===================================================="
5 echo starting compile_wkc
7 setenv WKC_DIRNAME KPP
9 setenv WRFC_ROOT `pwd`
10 setenv WKC_HOME ${WRFC_ROOT}/chem/${WKC_DIRNAME}
14 # KPP_HOME: environment variable needed by KPP
15 # note: this is not plain KPP
16 setenv KPP_HOME ${WKC_HOME}/kpp/kpp-2.1
17 mkdir -p ${KPP_HOME}/bin
18 setenv WKC_KPP ${KPP_HOME}/bin/kpp
21 #write Makefile_kpp.defs
22 rm -f ${WKC_HOME}/configure.kpp
23 ${WKC_HOME}/configure_kpp
25 # ...and link it
26 rm -f ${KPP_HOME}/Makefile.defs
27 ln -s ${WKC_HOME}/configure.kpp ${KPP_HOME}/Makefile.defs
30 # some preliminaries
31 if (! -e chem/Makefile_org ) then
32 cp chem/Makefile chem/Makefile_org
33 endif
35 if ( ! -e chem/module_wkppc_constants.F ) then
36 ln -s ${WKC_DIRNAME}/module_wkppc_constants.F chem
37 endif
40 #compile kpp
41 echo compile kpp
42 cd $KPP_HOME; make; cd $WRFC_ROOT
44 echo "-----------------------------------------"
47 ( cd $WKC_HOME/util/wkc; ./linker.csh unlink )
49 ( cd $WKC_HOME/util/wkc; ./linker.csh link )
51 #compile the coupler
52 echo compile the coupler
53 cd $WKC_HOME/util/wkc; make -i -r
55 #compile the tuv_kpp
56 echo compile the tuv_kpp
57 make -f Makefile.tuv
59 echo "-----------------------------------------"
61 # if Registry was edited touch run_wkc
62 echo check if Registry was touched
63 cd $WKC_HOME/util; make
65 echo "-----------------------------------------"
66 echo "Run kpp for mechanisms in chem/KPP/mechanisms"
70 # run make (-> kpp) in each subdir
72 cd $WKC_HOME
73 set kpp_files = ( mechanisms/*/*.kpp )
75 # Remove tuv inc files
76 set found = 0
77 if ( -e ${WRFC_ROOT}/inc/tuv2wrf_jvals.inc ) then
78 rm -f ${WRFC_ROOT}/inc/tuv2wrf_jvals.inc;
79 endif
80 if ( -e ${WRFC_ROOT}/inc/tuvdef_jvals.inc ) then
81 rm -f ${WRFC_ROOT}/inc/tuvdef_jvals.inc;
82 endif
84 foreach file ( $kpp_files )
86 echo "========================================================="
88 set kdir = `echo $file:h`
89 set kfile = `echo $file:t`
90 echo $kdir
92 if (! -e $kdir/Makefile ) then
93 rm -f $kdir/Makefile
94 echo ln -s ../../util/Makefile_kpp $kdir/Makefile
95 ln -s ../../util/Makefile_kpp $kdir/Makefile
96 endif
99 set model = `echo $kfile | sed 's/.kpp//g'`
105 # if necessary, create a few .inc files in chem/KPP/inc
106 # which can be used to add code in the automatically
107 # generated files module_kpp_xxx_interface.f
108 # these files will not be removed during cleanup!!!
110 util/create_inc_files.csh $model
114 cd $kdir
115 echo model $model
116 make MODEL=$model KPP=$WKC_KPP WRFC_ROOT=$WRFC_ROOT
118 # generate tuv photolysis inc files
119 if( -e $model.tuv.jmap ) then
120 if( $found == 0 ) then
121 $WKC_HOME/util/wkc/tuv_kpp FIRST
122 set found = 1
123 endif
124 $WKC_HOME/util/wkc/tuv_kpp $model
125 endif
127 if ( `echo $WRFC_ROOT | awk '{print ( length ( $1 ) > 40 ) }' `) then
128 echo WARNING: If kpp fails here the path to WRF-Chem might be too long for yacc ...
129 endif
131 cd $WKC_HOME
134 # direct addressing in the decomp subroutine (similar to a code by
135 # Edwin Spee, CWI, Amsterdam)
136 ( cd ${WKC_HOME}/util/write_decomp; ./write_decom.csh ${model} ../../.. )
140 # finish tuv photolysis inc files
141 if( $found == 1 ) then
142 $WKC_HOME/util/wkc/tuv_kpp LAST
143 endif
145 echo "========================================================="
147 ###################################################
149 # link the remaining .inc files in chem/KPP/inc
150 set kincfiles = ( inc/*.inc )
152 foreach kincfile ( $kincfiles )
154 if ( ! -e ${WRFC_ROOT}/${kincfile} ) then
155 echo ln -s ../chem/${WKC_DIRNAME}/${kincfile} ${WRFC_ROOT}/inc
156 ln -s ../chem/${WKC_DIRNAME}/${kincfile} ${WRFC_ROOT}/inc
157 endif
163 ###################################################
165 ## run the coupler
166 if ( -e util/run_wkc ) then
167 echo " "
168 echo "RUN WRF-Chem KPP coupler ---------------------------"
170 cd $WRFC_ROOT
172 chem/KPP/util/wkc/registry_kpp -DDA_CORE=0 -DEM_CORE=1 -DBUILD_CHEM=1 Registry/Registry.EM_CHEM
174 cd $WKC_HOME
177 rm -f util/run_wkc
180 if ( $status ) then
182 echo "ERROR on exit KPP coupler"
184 else
187 echo " back from KPP coupler: check generated code in chem directory"
189 endif
191 else
193 echo " not running the WRF-Chem KPP coupler"
195 endif
199 echo end of compile_wkc
200 echo "========================================================="
202 exit 0