#!/bin/bash
# ------------------------------------------------------------------------------
# Programmer(s): Radu Serban, David J. Gardner, Cody J. Balos @ LLNL
# ------------------------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2022, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ------------------------------------------------------------------------------
# Script to add CVODES files to a SUNDIALS tar-file.
# ------------------------------------------------------------------------------

set -e

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
    $tar $tarfile $distrobase/doc/cvodes/cvs_examples.pdf
fi
$tar $tarfile $distrobase/doc/cvodes/guide/Makefile
$tar $tarfile $distrobase/doc/cvodes/guide/source

$tar $tarfile $distrobase/include/cvodes/cvodes.h
$tar $tarfile $distrobase/include/cvodes/cvodes_bandpre.h
$tar $tarfile $distrobase/include/cvodes/cvodes_bbdpre.h
$tar $tarfile $distrobase/include/cvodes/cvodes_diag.h
$tar $tarfile $distrobase/include/cvodes/cvodes_direct.h
$tar $tarfile $distrobase/include/cvodes/cvodes_ls.h
$tar $tarfile $distrobase/include/cvodes/cvodes_proj.h
$tar $tarfile $distrobase/include/cvodes/cvodes_spils.h

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

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

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

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

$tar $tarfile $distrobase/examples/cvodes/CMakeLists.txt

$tar $tarfile $distrobase/examples/cvodes/serial/README
$tar $tarfile $distrobase/examples/cvodes/serial/CMakeLists.txt
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bnd.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bndL.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bndL.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_bnd.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non_-sensi_sim_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAdvDiff_FSA_non_-sensi_stg_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAnalytic_mels.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsAnalytic_mels.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDirectDemo_ls.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDirectDemo_ls.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_sim_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_FSA_kry_-sensi_stg_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry_bp.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry_bp.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsDiurnal_kry.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsHessian_ASA_FSA.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsHessian_ASA_FSA.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls_1.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_ls_2.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_prec.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsKrylovDemo_prec.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsParticle_dns.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsParticle_dns.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsPendulum_dns.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsPendulum_dns.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_bkw1_stats.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_bkw2_stats.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_fwd_stats.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_dns_constraints.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_stats.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_constraints.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_constraints.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dnsL.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dnsL.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_klu.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_klu.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_sps.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_ASAi_sps.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_uw.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_dns_uw.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_stats_-sensi_sim_t.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_stats_-sensi_stg1_t.csv
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_-sensi_sim_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_-sensi_stg1_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_Switch.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_dns_constraints_-sensi_stg1_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_klu.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_klu_-sensi_stg1_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_sps.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_FSA_sps_-sensi_stg1_t.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_klu.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_klu.out
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_sps.c
$tar $tarfile $distrobase/examples/cvodes/serial/cvsRoberts_sps.out
$tar $tarfile $distrobase/examples/cvodes/serial/plot_cvsParticle.py
$tar $tarfile $distrobase/examples/cvodes/serial/plot_cvsPendulum.py

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

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

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

echo "   --- Add cvodes unit tests to $tarfile"

$tar $tarfile $distrobase/test/unit_tests/cvodes/CMakeLists.txt
$tar $tarfile $distrobase/test/unit_tests/cvodes/C_serial/CMakeLists.txt
$tar $tarfile $distrobase/test/unit_tests/cvodes/C_serial/cvs_test_getuserdata.c
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/CMakeLists.txt
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.cpp
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.hpp
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--dgmax_jbad_1.0.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--dgmax_lsetup_0.0.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_cf_0.5.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_max_ef_0.1_--small_nef_1.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_max_fs_2.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_min_ef_0.5.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_min_es_2_--small_nst_5.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_min_fx_1.0_--eta_max_fx_2.0.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_min_fx_1.0_--eta_min_0.5.out
$tar $tarfile $distrobase/test/unit_tests/cvodes/CXX_serial/cvs_test_kpr_--eta_min_gs_2.out
