#!/bin/tcsh
# ----------------------------------------------------------------------
#  "run_comb" - auto-generation script
#     This is a part of KUCRS:
#        Knowledge-basing Utilities for Complex Reaction Systems
#                     (c) 2002-2021 by A. Miyoshi, Hiroshima University
#                                last edited: Aug. 19, 2021
# ----------------------------------------------------------------------
#
# ----- combust --------------------------------------------
combust $1.inp > $1.log
if ($status != 0) then
  echo "error termination of combust - abort."
  exit(-1)
endif
#
# ----- trangen --------------------------------------------
trangen $1_thg.inp > $1_trn.log
if ($status != 0) then
  echo "error termination of trangen - abort."
  exit(-1)
endif
rm $1_trn.log
#
# ----- thermgen -------------------------------------------
thermgen $1_thg.inp $1_thg.lst > $1_thg.log
if ($status != 0) then
  echo "error termination of thermgen - abort."
  exit(-1)
endif
rm $1_thg.inp $1_thg.log
#
# ----- thermpac & pac99m ----------------------------------
thermpac $1_thg.lst $1_thg.i97 > $1_thp.log
if ($status != 0) then
  echo "error termination of thermpac - abort."
  exit(-1)
endif
pac99m $1_thg
c97to7m < $1_thg.c97 > $1_thg.dat
rm $1_thg.lst $1_thf.inp $1_thp.log $1_thg.i97 $1_thg.o97 $1_thg.c97 new.groups unf.EFdata
#
# ----- mol2smiles -----------------------------------------
mol2smiles $1_mol.dat $1.smiles -l > $1_m2s.log
if ($status != 0) then
  echo "error termination of mol2smiles - abort."
  exit(-1)
endif
cat $1_sp_.csv $KUCRS_LIB/mol_1_spc_add.csv > $1_spc.csv
cat $1_sp_.lst $KUCRS_LIB/mol_1_spc_add.lst > $1_spc.lst
cat $1.smiles $KUCRS_LIB/smiles_1_add.inp > $1_smiles.inp
rm $1_m2s.log $1_sp_.csv $1_sp_.lst $1.smiles
#
# ----- chemgen --------------------------------------------
chemgen $1_chg.inp $1_thg.dat > $1_chg.log
if ($status != 0) then
  echo "error termination of chemgen - abort."
  exit(-1)
endif
rm $1_chg.inp $1_thg.dat
#
# ----- bsmiles --------------------------------------------
bsmiles $1_thm.dat $1_spc.csv $1_the.dat > $1_bsm.log
if ($status != 0) then
  echo "error termination of bsmiles - abort."
  exit(-1)
endif
rm $1_spc.csv $1_thm.dat $1_bsm.log
cat $1_spc.inp $1_the.dat $1_rxn.inp > $1_chm.inp
rm $1_spc.inp $1_the.dat $1_rxn.inp $1_fue.log
rm $1_chg.log $1_mol.dat $1_mol.log $1_smiles.inp $1_spc.lst $1_snk.inp
#
echo normal termination of run_comb
