#!/bin/sh

tarfile=$1
distrobase=$2
doc=$3

# all remaining inputs are for tar command
shift 3
tar=$*

echo "   --- Add cvodes module to $tarfile"

if [ $doc = "T" ]; then
    $tar $tarfile $distrobase/doc/cvodes/cvs_guide.pdf    || exit 1
    $tar $tarfile $distrobase/doc/cvodes/cvs_examples.pdf || exit 1
fi

$tar $tarfile $distrobase/include/cvodes/cvodes.h         || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_bandpre.h || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_bbdpre.h  || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_diag.h    || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_direct.h  || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_ls.h      || exit 1
$tar $tarfile $distrobase/include/cvodes/cvodes_spils.h   || exit 1

$tar $tarfile $distrobase/src/cvodes/LICENSE        || exit 1
$tar $tarfile $distrobase/src/cvodes/NOTICE         || exit 1
$tar $tarfile $distrobase/src/cvodes/README.md      || exit 1
$tar $tarfile $distrobase/src/cvodes/CMakeLists.txt || exit 1

$tar $tarfile $distrobase/src/cvodes/cvodea.c              || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodea_io.c           || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_bandpre.c      || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_bandpre_impl.h || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_bbdpre.c       || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_bbdpre_impl.h  || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes.c              || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_diag.c         || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_diag_impl.h    || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_direct.c       || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_impl.h         || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_io.c           || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_ls.c           || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_ls_impl.h      || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_nls.c          || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_nls_sim.c      || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_nls_stg.c      || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_nls_stg1.c     || exit 1
$tar $tarfile $distrobase/src/cvodes/cvodes_spils.c        || exit 1

$tar $tarfile $distrobase/src/cvodes/fmod/CMakeLists.txt  || exit 1
$tar $tarfile $distrobase/src/cvodes/fmod/fcvodes_mod.c   || exit 1
$tar $tarfile $distrobase/src/cvodes/fmod/fcvodes_mod.f90 || exit 1

echo "   --- Add cvodes examples to $tarfile"

$tar $tarfile $distrobase/examples/cvodes/CMakeLists.txt || exit 1

$tar $tarfile $distrobase/examples/cvodes/serial/README                                           || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/CMakeLists.txt                                   || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bnd.c                                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bndL.c                                || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bndL.out                              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bnd.out                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non_-sensi_sim_t.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non_-sensi_stg_t.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAnalytic_mels.c                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAnalytic_mels.out                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDirectDemo_ls.c                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDirectDemo_ls.out                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry_bp.c                              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry_bp.out                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry.c                                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry.out                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsHessian_ASA_FSA.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsHessian_ASA_FSA.out                           || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls.c                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls.out                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls_1.out                           || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls_2.out                           || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_prec.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_prec.out                           || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c                || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns.c                                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns.out                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_constraints.c                     || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_constraints.out                   || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dnsL.c                                || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dnsL.out                              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_klu.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_klu.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_sps.c                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_sps.out                          || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_uw.c                              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_uw.out                            || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_-sensi_sim_t.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_-sensi_stg1_t.out             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.out                    || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c                      || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints_-sensi_stg1_t.out || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_klu.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_klu_-sensi_stg1_t.out             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_sps.c                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_sps_-sensi_stg1_t.out             || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_klu.c                                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_klu.out                               || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_sps.c                                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_sps.out                               || exit 1

$tar $tarfile $distrobase/examples/cvodes/C_openmp/README                 || exit 1
$tar $tarfile $distrobase/examples/cvodes/C_openmp/CMakeLists.txt         || exit 1
$tar $tarfile $distrobase/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c   || exit 1
$tar $tarfile $distrobase/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.out || exit 1

$tar $tarfile $distrobase/examples/cvodes/parallel/README                                || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/CMakeLists.txt                        || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c               || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.out             || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c                || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p_-sensi_sim_t.out || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p_-sensi_stg_t.out || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_non_p.c                    || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAdvDiff_non_p.out                  || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c           || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out         || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c                || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_sim_t.out || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p_-sensi_stg_t.out || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c                || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.out              || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_kry_p.c                    || exit 1
$tar $tarfile $distrobase/examples/cvodes/parallel/cvsDiurnal_kry_p.out                  || exit 1

$tar $tarfile $distrobase/examples/cvodes/F2003_serial/README                                     || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/CMakeLists.txt                             || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/cvs_analytic_fp_f2003.f90                  || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/cvs_analytic_fp_f2003.out                  || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/cvsAdvDiff_FSA_non_f2003.f90               || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/cvsAdvDiff_FSA_non_f2003_-sensi_sim_t.out  || exit 1
$tar $tarfile $distrobase/examples/cvodes/F2003_serial/cvsAdvDiff_FSA_non_f2003_-sensi_stg_t.out  || exit 1
