source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/bin/kpp4palm.ksh @ 2968

Last change on this file since 2968 was 2718, checked in by maronga, 7 years ago

deleting of deprecated files; headers updated where needed

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 7.3 KB
Line 
1#!/usr/bin/ksh
2
3# kpp4palm - script for creating gasphase module
4
5#------------------------------------------------------------------------------#
6# This file is part of the PALM model system.
7#
8# PALM is free software: you can redistribute it and/or modify it under the terms
9# of the GNU General Public License as published by the Free Software Foundation,
10# either version 3 of the License, or (at your option) any later version.
11#
12# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along with
17# PALM. If not, see <http://www.gnu.org/licenses/>.
18#
19# Copyright 2017-2018  Klaus Ketelsen and MPI-CH (April 2007)
20# Copyright 2017-2018  Karlsruhe Institute of Technology
21# Copyright 2017-2018  Leibniz Universitaet Hannover
22#------------------------------------------------------------------------------#
23#
24# Current revisions:
25# ------------------
26#
27#
28# Former revisions:
29# -----------------
30# $Id: kpp4palm.ksh 2718 2018-01-02 08:49:38Z suehring $
31# Initial revision
32#
33#
34#
35#
36# Other notes:
37# ------------#
38# Re-introduced relative path for KPP_HOME
39# Subroutine list adapted to lowercase subroutine names
40# Added arr2, removed update_sun and k_3rd from subroutine list
41# Renamed output file to chem_gasphase_mod
42# Renamed this fikle from kp4/ksh to kpp4kpp.ksh
43# changed location of def_mechanism directories to GASPHASE_PREPROC/mechanisms
44#
45# Nov. 2016: Initial Version of KPP chemistry convertor by Klaus Ketelsen
46#
47#
48
49set -eu
50
51
52########################### User SetUp ####################################
53
54export KPP_HOME=`pwd`/kpp
55export KPP=$KPP_HOME/bin/kpp
56
57BASE=`pwd`/kpp4palm
58
59########################## End User Setup ################################
60
61WORK=tmp_kpp4palm
62
63# Default
64
65OUTDIR=`pwd`/../../../SOURCE
66OUTFILE=chem_gasphase_mod
67DEFDIR=`pwd`/mechanisms/def_smog
68PREFIX=chem_gasphase_mod
69MODE="scalar"
70VLEN=1
71KEEP="NO"
72DE_INDEX="NO"
73DE_INDEX_FAST="NO"
74
75export KPP_SOLVER=Rosenbrock
76
77# get Command line option
78
79echo xxxxxxxxxx
80while  getopts :d:ifkp:o:s:v:w:  c     # get options
81do case $c in
82      d)   DEFDIR=$OPTARG;;          # directory of definition files
83
84      i)   DE_INDEX="YES";;          # if set, deindexing
85
86      f)   DE_INDEX_FAST="YES";;     # if set, fast deindexing
87
88      k)   KEEP="YES";;              # keep Working directory
89
90      o)   OUTDIR=$OPTARG;;          # Output directory of Generated Code
91
92      p)   PREFIX=$OPTARG;;          # Name Prefix
93
94      s)   KPP_SOLVER=$OPTARG;;      # Name Prefix
95
96      v)   MODE="vector"
97           VLEN=$OPTARG;;            # Set to vector Mode
98
99      w)   WORK=$OPTARG;;            # Working directory
100
101      \?)  print ${0##*/} "unknown option:" $OPTARG
102           print "USAGE: ${0##*/} [ -d dir -e -k -o dir -p name -s solver -v length -w dir ] "
103           exit 1;;
104   esac
105done
106shift OPTIND-1
107
108echo $DEFDIR
109
110DEF_PREFIX=${PREFIX}.kpp
111
112# Create or clean working directory
113
114MY_PWD=`pwd`
115mkdir -p $WORK
116rm -rf $WORK/*
117cd $WORK
118
119# kpp dependend, may be changed
120
121KPP_FILE_LIST="Initialize Integrator LinearAlgebra Jacobian Function Rates Util"
122
123
124KPP_SUBROUTINE_LIST="initialize"
125KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST integrate fun"
126KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST kppsolve kppdecomp wlamch wlamch_add"
127KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST jac_sp k_arr "
128KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST update_rconst arr2"
129KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST initialize_kpp_ctrl error_output"
130
131# if [[ $MODE = "vector" && $KPP_SOLVER = "ROS2" ]]
132# then
133#   cp $BASE/templates/${KPP_SOLVER}_vec.f90 ${KPP_SOLVER}.f90    # get vector Solver
134# else
135# #  KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST FunTemplate JacTemplate Update_SUN "
136#   KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
137#   if [[ $MODE = "vector" ]]
138#   then
139#     cp $BASE/templates/${KPP_SOLVER}_vec.f90 ${KPP_SOLVER}.f90  # get vector Solver
140#   else
141#     KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Rosenbrock  FunTemplate JacTemplate Update_SUN"
142#   fi
143# fi
144 if [[ $MODE = "vector" ]]
145 then
146   # get vector Solver
147   cp $BASE/templates/${KPP_SOLVER}_vec.f90 ${KPP_SOLVER}.f90
148fi
149
150# Interface ignore list
151KPP_INTERFACE_IGNORE="waxpy wcopy"
152
153case $KPP_SOLVER in
154    ROS2) ;;
155
156    Rosenbrock)   
157      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST wcopy wscal waxpy"
158    if [[ $MODE != "vector" ]]
159    then
160      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST rosenbrock  funtemplate jactemplate"
161    fi;;
162
163    rosenbrock_mz)
164      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
165      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Rosenbrock  FunTemplate JacTemplate Update_SUN";;
166
167    rosenbrock)
168      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
169      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST rosenbrock  funtemplate jactemplate";;
170
171    kpp_lsode)
172      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
173      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST KppLsode DLSODE JAC_CHEM FUN_CHEM"
174      KPP_INTERFACE_IGNORE="$KPP_INTERFACE_IGNORE JAC_CHEM KppDecomp KppSolve";;
175
176    kpp_radau5)
177      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY FUN_CHEM JAC_CHEM SET2ZERO"
178      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST RADAU5 Update_SUN"
179      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST KppSolveCmplx KppDecompCmplx";;
180
181    kpp_sdirk)
182       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
183       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST SDIRK JAC_CHEM SET2ZERO FUN_CHEM"
184       KPP_INTERFACE_IGNORE="$KPP_INTERFACE_IGNORE Set2zero SET2ZERO FUN_CHEM";;
185
186    kpp_seulex)
187       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
188       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST ATMSEULEX"
189       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST SEULEX_ErrorMsg SEULEX_Integrator FUN_CHEM JAC_CHEM SEUL"
190       KPP_INTERFACE_IGNORE="$KPP_INTERFACE_IGNORE SEULEX_Integrator SDIRK FUN_CHEM SEUL";;
191
192   \?)  print "SORRY ONLY ROSENBROCK METHODS WORK AT THE MOMENT:" $KPP_SOLVER
193        exit 1;;
194esac
195#mz-ak-20070509+
196
197KPP_INCLUDE_LIST="Parameters Global JacobianSP Monitor"
198
199#Get definition Files
200
201cp $DEFDIR/*.eqn         .
202cp $DEFDIR/*.spc         .
203cp $DEFDIR/${PREFIX}.kpp     .
204
205# Run kpp
206
207$KPP $DEF_PREFIX
208
209# Get templates for C++ program
210
211cp $BASE/templates/module_header* .           # Use fixed Module_header
212cp $BASE/templates/initialize_kpp_ctrl_template.f90 .  # CTRL kpp time stepping
213
214# file with subroutine list for c++ program create_kpp_module
215
216for i in $KPP_FILE_LIST
217do
218  echo ${PREFIX}_${i} >> file_list
219done
220echo initialize_kpp_ctrl_template >> file_list
221
222# file with subroutine list for c++ program create_kpp_module
223
224for i in $KPP_SUBROUTINE_LIST
225do
226  echo $i >> subroutine_list
227done
228
229# file with include list for c++ program create_kpp_module
230
231for i in $KPP_INCLUDE_LIST
232do
233  echo ${PREFIX}_${i} >> include_list
234done
235
236touch interface_ignore_list
237for i in $KPP_INTERFACE_IGNORE
238do
239  echo $i >> interface_ignore_list
240done
241
242$BASE/bin/kpp4palm.exe $PREFIX $MODE $VLEN $DE_INDEX $DE_INDEX_FAST
243
244
245if [[ -e $OUTDIR/${OUTFILE}.f90 ]] 
246then
247 mv $OUTDIR/${OUTFILE}.f90 $OUTDIR/${OUTFILE}.f90.sav
248fi
249cp -p kk_kpp.f90    $OUTDIR/${OUTFILE}.f90
250#cp -p kk_kpp.f90    $MY_PWD/../SOURCE/${OUTFILE}.f90
251
252echo " "
253echo "Write kpp module -- > " $OUTDIR/${OUTFILE}.f90
254
255if [[ $KEEP = "NO" ]]
256then
257  cd  $MY_PWD
258  rm -rf $WORK
259fi
260exit
261
Note: See TracBrowser for help on using the repository browser.