Ignore:
Timestamp:
Oct 2, 2018 12:21:11 PM (4 years ago)
Author:
kanani
Message:

Merge chemistry branch at r3297 to trunk

Location:
palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/UTIL/chemistry/gasphase_preproc/kpp4palm/bin/kpp4palm.ksh

    r2718 r3298  
    2121# Copyright 2017-2018  Leibniz Universitaet Hannover
    2222#------------------------------------------------------------------------------#
     23# Nov. 2016: Initial Version of KPP chemistry convertor adapted for PALM
     24# by Klaus Ketelsen
     25#
     26# This code is a modified version of KP4 (Jöckel, P., Kerkweg, A., Pozzer, A.,
     27# Sander, R., Tost, H., Riede, H., Baumgaertner, A., Gromov, S., and Kern, B.,
     28# 2010: Development cycle 2 of the Modular Earth Submodel System (MESSy2),
     29# Geosci. Model Dev., 3, 717-752, https://doi.org/10.5194/gmd-3-717-2010).
     30# KP4 is part of the Modular Earth Submodel System (MESSy), which is is
     31# available under the  GNU General Public License (GPL).
     32#
     33#------------------------------------------------------------------------------#
    2334#
    2435# Current revisions:
     
    2940# -----------------
    3041# $Id$
     42# forkel   25. September 2018: Added cat for $MECH to pass mechanism name to kpp4palm
     43# ketelsen 18. September 2018: Added cat for '#INLINE F90_GLOBAL'
     44# (moved here from mechanisms/def_MECH/chem_gasphase.kpp
     45#
     46# forkel: 14. September  2018: WCOPY removed
     47# ketelsen: July 2018: Adaptations for vektor mode
     48# forkel June 2018: re-established original case of subroutine names
     49# forkel May 2018: additional copying of chem_gasphase_mod.f90 into $DEFDIR
     50# forkel 20.04.2018: removed  wlamch and wlamch_add from $KPP_SUBROUTINE_LIST
     51#                    (epsilon(one) is used now)
     52# forkel March 2017
     53# Re-introduced relative path for KPP_HOME
     54# Subroutine list adapted to lowercase subroutine names
     55# Added arr2, removed update_sun and k_3rd from subroutine list
     56# Renamed output file to chem_gasphase_mod
     57# Renamed this file from kp4/ksh to kpp4kpp.ksh
     58# changed location of def_mechanism directories to gasphase_preproc/mechanisms
     59#
     60#
     61# 2718 2018-01-02 08:49:38Z maronga
    3162# Initial revision
    3263#
    3364#
     65##########################################################################
    3466#
    3567#
     
    6395# Default
    6496
     97MECH=smog
    6598OUTDIR=`pwd`/../../../SOURCE
    6699OUTFILE=chem_gasphase_mod
     
    70103VLEN=1
    71104KEEP="NO"
    72 DE_INDEX="NO"
    73 DE_INDEX_FAST="NO"
     105UPDT="NO"
     106DE_INDEX=0
     107DE_INDEX_FAST="YES"
    74108
    75109export KPP_SOLVER=Rosenbrock
     
    77111# get Command line option
    78112
    79 echo xxxxxxxxxx
    80 while  getopts :d:ifkp:o:s:v:w:  c     # get options
     113while  getopts :m:i:fkup:o:s:vl:w:  c     # get options
    81114do case $c in
    82       d)   DEFDIR=$OPTARG;;          # directory of definition files
    83 
    84       i)   DE_INDEX="YES";;          # if set, deindexing
     115      m)   MECH=$OPTARG;;            # mechanism
     116
     117      i)   DE_INDEX=$OPTARG;;        # if set, deindexing
    85118
    86119      f)   DE_INDEX_FAST="YES";;     # if set, fast deindexing
     
    92125      p)   PREFIX=$OPTARG;;          # Name Prefix
    93126
    94       s)   KPP_SOLVER=$OPTARG;;      # Name Prefix
    95 
    96       v)   MODE="vector"
    97            VLEN=$OPTARG;;            # Set to vector Mode
     127      s)   KPP_SOLVER=$OPTARG;;      # Update sample f90 code in the def_MECH directory
     128
     129      u)   UPDT="YES";;              # keep Working directory
     130
     131      v)   MODE="vector";;           # Set to vector Mode
     132
     133      l)   VLEN=$OPTARG;;            # Set vector length
    98134
    99135      w)   WORK=$OPTARG;;            # Working directory
    100136
    101137      \?)  print ${0##*/} "unknown option:" $OPTARG
    102            print "USAGE: ${0##*/} [ -d dir -e -k -o dir -p name -s solver -v length -w dir ] "
     138           print "USAGE: ${0##*/} [ -m dir -e -k -u -o dir -p name -s solver -v -l length -w dir ] "
    103139           exit 1;;
    104140   esac
     
    106142shift OPTIND-1
    107143
    108 echo $DEFDIR
     144echo MECHANISM = $MECH
     145echo DE_INDEX = $DE_INDEX
     146echo KEEP = $KEEP
     147echo UPDT = $UPDT
     148echo MODE = $MODE
     149echo VLEN = $VLEN
    109150
    110151DEF_PREFIX=${PREFIX}.kpp
     152DEFDIR=`pwd`/mechanisms/def_$MECH
     153echo DEFDIR = $DEFDIR
    111154
    112155# Create or clean working directory
     
    122165
    123166
    124 KPP_SUBROUTINE_LIST="initialize"
    125 KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST integrate fun"
    126 KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST kppsolve kppdecomp wlamch wlamch_add"
    127 KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST jac_sp k_arr "
    128 KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST update_rconst arr2"
     167KPP_SUBROUTINE_LIST="Initialize"
     168KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST INTEGRATE Fun"
     169KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST KppSolve KppDecomp"
     170KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Jac_SP k_arr "
     171KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Update_RCONST ARR2"
    129172KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST initialize_kpp_ctrl error_output"
    130173
     
    149192
    150193# Interface ignore list
    151 KPP_INTERFACE_IGNORE="waxpy wcopy"
     194KPP_INTERFACE_IGNORE=" "
     195
     196echo " "
     197echo KPP_SOLVER $KPP_SOLVER
     198echo " "
    152199
    153200case $KPP_SOLVER in
     
    155202
    156203    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;;
     204      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WSCAL WAXPY"
     205      if [[ $MODE != "vector" ]]
     206      then
     207         KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Rosenbrock  FunTemplate JacTemplate"
     208        KPP_INTERFACE_IGNORE="WAXPY"
     209      else
     210        KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST FunTemplate JacTemplate"
     211      fi;;
    162212
    163213    rosenbrock_mz)
     
    167217    rosenbrock)
    168218      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST WCOPY WSCAL WAXPY"
    169       KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST rosenbrock  funtemplate jactemplate";;
     219      KPP_SUBROUTINE_LIST="$KPP_SUBROUTINE_LIST Rosenbrock  FunTemplate JacTemplate";;
    170220
    171221    kpp_lsode)
     
    203253cp $DEFDIR/${PREFIX}.kpp     .
    204254
     255# Global variable are defined here
     256# This has the advantage that it is not necessary to include these variables in all .kpp definition files
     257
     258cat  >> ${PREFIX}.kpp  <<  EOF
     259#INLINE F90_GLOBAL
     260! QVAP - Water vapor
     261  REAL(kind=dp) :: QVAP
     262! FAKT - Conversion factor
     263  REAL(kind=dp) :: FAKT
     264
     265#ENDINLINE
     266EOF
     267
     268# Store mechanism name in file mech_list
     269cat  >> mech_list  <<  EOF
     270!   Mechanism: $MECH
     271!
     272EOF
     273
    205274# Run kpp
    206275
     
    240309done
    241310
     311echo start kp4.exe with arguments
     312echo $PREFIX $MODE $VLEN $DE_INDEX $DE_INDEX_FAST
     313
    242314$BASE/bin/kpp4palm.exe $PREFIX $MODE $VLEN $DE_INDEX $DE_INDEX_FAST
    243315
     316#Prelimanary, substitution has to be moved into kpp4palm.exe
     317if [[ $MODE = "vector" ]]
     318then
     319  sed -i -e 's/phot(nphot/phot(vl_dim,nphot/g' kk_kpp.f90
     320fi
    244321
    245322if [[ -e $OUTDIR/${OUTFILE}.f90 ]]
     
    248325fi
    249326cp -p kk_kpp.f90    $OUTDIR/${OUTFILE}.f90
    250 #cp -p kk_kpp.f90    $MY_PWD/../SOURCE/${OUTFILE}.f90
    251 
    252327echo " "
    253328echo "Write kpp module -- > " $OUTDIR/${OUTFILE}.f90
     329
     330if [[ $UPDT = "YES" ]]
     331then
     332cp -p kk_kpp.f90    $DEFDIR/${OUTFILE}.f90
     333echo " "
     334echo "Write kpp module -- > " $DEFDIR/${OUTFILE}.f90
     335fi
    254336
    255337if [[ $KEEP = "NO" ]]
Note: See TracChangeset for help on using the changeset viewer.